Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not see the logs(using log4j) using @Loggable #179

Open
kumarvijaypt opened this issue Sep 4, 2015 · 5 comments
Open

Do not see the logs(using log4j) using @Loggable #179

kumarvijaypt opened this issue Sep 4, 2015 · 5 comments

Comments

@kumarvijaypt
Copy link

Hi @yegor256 ,

I was trying to follow the link http://www.yegor256.com/2014/06/01/aop-aspectj-java-method-logging.html. However I was unable to find any logs.

Running with JavaSE-1.6
Details:
Project structure:

image

Pom:

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <java.source-target.version>1.6</java.source-target.version>
    <aspectj.version>1.8.5</aspectj.version>
  </properties>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.aspectj</groupId>
      <artifactId>aspectjrt</artifactId>
      <version>${aspectj.version}</version>
    </dependency>

    <dependency>
        <groupId>com.jcabi</groupId>
        <artifactId>jcabi-aspects</artifactId>
        <version>0.22</version>
    </dependency>
    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.17</version>
    </dependency>
  </dependencies>
  <build>
    <plugins>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.3</version>
        <configuration>
          <source>${java.source-target.version}</source>
          <target>${java.source-target.version}</target>
          <!-- IMPORTANT -->
          <useIncrementalCompilation>false</useIncrementalCompilation>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>aspectj-maven-plugin</artifactId>
        <version>1.7</version>
        <configuration>
          <source>${java.source-target.version}</source>
          <target>${java.source-target.version}</target>
          <Xlint>ignore</Xlint>
          <complianceLevel>${java.source-target.version}</complianceLevel>
          <encoding>${project.build.sourceEncoding}</encoding>
          <!--<verbose>true</verbose> -->
          <!--<warn>constructorName,packageDefaultMethod,deprecation,maskedCatchBlocks,unusedLocals,unusedArguments,unusedImport</warn> -->
        </configuration>
        <executions>
          <execution>
            <!-- IMPORTANT -->
            <phase>process-sources</phase>
            <goals>
              <goal>compile</goal>
              <goal>test-compile</goal>
            </goals>
          </execution>
        </executions>
        <dependencies>
          <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjtools</artifactId>
            <version>${aspectj.version}</version>
          </dependency>
        </dependencies>
      </plugin>
    </plugins>
  </build>
</project>

log4j.properties file in resource directory:

log4j.rootLogger=INFO, file, CONSOLE
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=jcabi.log
log4j.appender.file.MaxFileSize=10MB
log4j.appender.file.MaxBackupIndex=1
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n

log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.layout=com.jcabi.log.MulticolorLayout
log4j.appender.CONSOLE.layout.ConversionPattern=[%color{%-5p}] %c: %m%n

Loggable class:

package com.amadeus.logging.samplelogging;

import com.jcabi.aspects.Loggable;

@Loggable(Loggable.INFO)
public class Flight {

  private int flightID;

  public void setFlightID(int flightID) {
    this.flightID = flightID;
  }

  public int getFlightID() {
    return flightID;
  }

}

Caller class:

package com.amadeus.logging.samplelogging;

/**
 * Hello world!
 *
 */
public class App
{
    public static void main( String[] args )
    {
        Flight f = new Flight();
        f.setFlightID(0);
    }
}
@kumarvijaypt
Copy link
Author

I updated the pom. It started working

image

@kumarvijaypt
Copy link
Author

@yegor256 Thanks for great lib. I loved it!

@yegor256
Copy link
Member

yegor256 commented Sep 8, 2015

@kumarvijaypt please close the ticket if everything is fine now. thanks for using the lib :)

@paramitanit
Copy link

i have problem, logs are not writing for me too. i used the class files, pom.xml as above, but the pom xml showing error.I m attaching the error and also the pom.xml file..please help me asap
pom
pom.txt

@paramitanit
Copy link

@kumarvijaypt please share ur complete pom.xml file, if u have, its really urgent

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants