Logging Spring using Log4j2 -
i'm trying use log4j2 print spring logs file , console. guess problem in log4j2 configuration. have not been able working. have configuration in log4j2.xml file:
<?xml version="1.0" encoding="utf-8"?> <configuration name="defaultconfiguration" status="warn" strict="true" monitorinterval="5"> <properties> <property name="patternlayout">%d{iso8601} [%t] %-5level %logger{36} - %msg%n%throwable{full}</property> <property name="filename">${env:my_root}/logs/mylog.log</property> <property name="filenamepattern">${env:my_root}/logs/mylog-%d{yyyy-dd-mm}-%i.log.gz</property> </properties> <appenders> <appender name="console" type="console" target="system_out"> <layout type="patternlayout" pattern="${patternlayout}" /> </appender> <appender name="file" type="rollingfile" filename="${filename}" filepattern="${filenamepattern}" bufferedio="true" immediateflush="true" append="true"> <layout type="patternlayout" pattern="${patternlayout}" /> <policies> <timebasedtriggeringpolicy /> <sizebasedtriggeringpolicy size="50 mb" /> </policies> <defaultrolloverstrategy max="30" /> </appender> <appender name="asynchfile" type="asynch" blocking="true" buffersize="128"> <appender-ref ref="file" /> </appender> </appenders> <loggers> <root level="info"> <appender-ref ref="console" /> <appender-ref ref="asynchfile" /> </root> <logger name="org.springframework.beans"> <appender-ref ref="console" /> <appender-ref ref="asynchfile" /> </logger> </loggers> </configuration>
these dependencies have in pom file: (probably of them not required)
<dependency> <groupid>org.slf4j</groupid> <artifactid>slf4j-api</artifactid> <version>1.6.6</version> </dependency> <dependency> <groupid>org.slf4j</groupid> <artifactid>slf4j-log4j12</artifactid> <version>1.6.6</version> </dependency> <dependency> <groupid>org.apache.logging.log4j</groupid> <artifactid>log4j-api</artifactid> <version>2.0-beta5</version> </dependency> <dependency> <groupid>org.apache.logging.log4j</groupid> <artifactid>log4j-core</artifactid> <version>2.0-beta5</version> </dependency> <dependency> <groupid>org.apache.logging.log4j</groupid> <artifactid>log4j-1.2-api</artifactid> <version>2.0-beta5</version> </dependency> <dependency> <groupid>com.lmax</groupid> <artifactid>disruptor</artifactid> <version>3.0.0.beta3</version> </dependency>
i'm not doing related spring in java code. i'm using main class apache camel reads spring configuration , loads beans.
what doing wrong? thanks!
edit: not getting spring logs in output (console or file). however, able logs create in java code. hope clarification help.
looking @ dependencies in pom, have one: slf4j-log4j12. causes log statements against slf4j api routed log4j-1.2 implementation. want these routed log4j-2.0 implementation. can replace slf4j-log4j12 log4j-slf4j-impl , try again?
Comments
Post a Comment