Steps to implement logging in core Java
Eclipse – include libraries ie logback-classic,core,access,slf4j-api.
Sample program
package testlogger;
import org.apache.log4j.PropertyConfigurator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.PatternLayout;
import ch.qos.logback.classic.spi.LoggingEvent;
import ch.qos.logback.core.FileAppender;
import ch.qos.logback.core.util.StatusPrinter;
public class LoggerMain {
private final Logger logger =LoggerFactory.getLogger(getClass());
public static void main(String[]args) {
// PropertyConfigurator.configure("log4j.properties");
newConfigureLogBack();
LoggerMainlm = new LoggerMain();
lm.putLogger();
}
public void putLogger() {
LoggerContextlc = (LoggerContext) LoggerFactory.getILoggerFactory();
StatusPrinter.print(lc);
logger.info("Hello");
}
}
In the classpath user librabries set the location of logback.xml
<configuration>
<substitutionProperty name="log.dir"value="D:\\logging\\" />
<substitutionProperty name="log.file"value="${logback.file.name}" />
<appender name="STDOUT"
class="ch.qos.logback.core.ConsoleAppender">
<layoutclass="ch.qos.logback.classic.PatternLayout">
<Pattern>%d{yyyyMMdd-HH:mm:ss.SSSZ} [%thread] %-5level %logger.%method -%msg%n</Pattern>
</layout>
</appender>
<appender name="STDOUT_inforeach"class="ch.qos.logback.core.ConsoleAppender">
<layoutclass="ch.qos.logback.classic.PatternLayout">
<Pattern>%date{HH:mm:ss.SSS} %level %msg%n</Pattern>
</layout>
</appender>
<appender name="FILE_DATE_ROLL"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.dir}/${log.file}.log</file>
<Append>true</Append>
<Encoding>UTF-8</Encoding>
<BufferedIO>false</BufferedIO>
<BufferSize>8192</BufferSize>
<ImmediateFlush>true</ImmediateFlush>
<rollingPolicy
class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<FileNamePattern>
${log.dir}/bak/${log.file}-%d{yyyy-MM-dd}.log.zip
</FileNamePattern>
</rollingPolicy>
<layoutclass="ch.qos.logback.classic.PatternLayout">
<Pattern>%d{yyyyMMdd-HH:mm:ss.SSSZ} [%thread] %-5level %logger.%method -%msg%n</Pattern>
</layout>
</appender>
<appender name="FILE_SIZE_ROLL"class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.dir}/${log.file}.log</file>
<Append>true</Append>
<Encoding>UTF-8</Encoding>
<BufferedIO>false</BufferedIO>
<BufferSize>8192</BufferSize>
<ImmediateFlush>true</ImmediateFlush>
<rollingPolicyclass="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
<FileNamePattern>
${log.dir}/bak/${log.file}-%i.log.zip
</FileNamePattern>
<MinIndex>0</MinIndex>
<MaxIndex>9</MaxIndex>
</rollingPolicy>
<triggeringPolicyclass="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<MaxFileSize>50MB</MaxFileSize>
</triggeringPolicy>
<layoutclass="ch.qos.logback.classic.PatternLayout">
<Pattern>%d{yyyyMMdd-HH:mm:ss.SSSZ} [%thread] %-5level %logger.%method -%msg%n</Pattern>
</layout>
</appender>
<root>
<level value="ALL" />
<appender-ref ref="STDOUT" />
<appender-ref ref="FILE_SIZE_ROLL"/>
</root>
<loggername="com.inforeach.util.log.Slf4jLogger">
<level value="DEBUG" />
</logger>
<logger name="org.logicalcobwebs.proxool">
<level value="DEBUG" />
</logger>
<logger name="testlogger.LoggerMain">
<level value="ALL" />
</logger>
</configuration>
In Eclipse Run Configuration ->Arguments ->VM set
-Dlogback.file.name=Test
5Run the application it should out put the resut in the out folder mentioned atthe top
Jars needed
logback-classic-0.9.8.jar
logback-core-0.9.8.jar
slf4j-api-1.4.3.jar
jcl104-over-slf4j-1.4.3.jar
logback-access-0.9.8.jar
Place the logback.xml file in the config folder and pass that config folder as librabry from build path as add classpath- Show quoted text -
On Tue, Feb 23, 2010 at 3:32 AM, Harshal Shah <harshals@synechron.com> wrote:
Steps to implement logging in core Java
Eclipse – include libraries ie logback-classic,core,access,slf4j-api.
Sample program
package testlogger;
import org.apache.log4j.PropertyConfigurator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.PatternLayout;
import ch.qos.logback.classic.spi.LoggingEvent;
import ch.qos.logback.core.FileAppender;
import ch.qos.logback.core.util.StatusPrinter;
public class LoggerMain {
private final Logger logger =LoggerFactory.getLogger(getClass());
public static void main(String[]args) {
// PropertyConfigurator.configure("log4j.properties");
newConfigureLogBack();
LoggerMainlm = new LoggerMain();
lm.putLogger();
}
public void putLogger() {
LoggerContextlc = (LoggerContext) LoggerFactory.getILoggerFactory();
StatusPrinter.print(lc);
logger.info("Hello");
}
}
In the classpath user librabries set the location of logback.xml
<configuration>
<substitutionProperty name="log.dir"value="D:\\logging\\" />
<substitutionProperty name="log.file"value="${logback.file.name}" />
<appender name="STDOUT"
class="ch.qos.logback.core.ConsoleAppender">
<layoutclass="ch.qos.logback.classic.PatternLayout">
<Pattern>%d{yyyyMMdd-HH:mm:ss.SSSZ} [%thread] %-5level %logger.%method -%msg%n</Pattern>
</layout>
</appender>
<appender name="STDOUT_inforeach"class="ch.qos.logback.core.ConsoleAppender">
<layoutclass="ch.qos.logback.classic.PatternLayout">
<Pattern>%date{HH:mm:ss.SSS} %level %msg%n</Pattern>
</layout>
</appender>
<appender name="FILE_DATE_ROLL"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.dir}/${log.file}.log</file>
<Append>true</Append>
<Encoding>UTF-8</Encoding>
<BufferedIO>false</BufferedIO>
<BufferSize>8192</BufferSize>
<ImmediateFlush>true</ImmediateFlush>
<rollingPolicy
class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<FileNamePattern>
${log.dir}/bak/${log.file}-%d{yyyy-MM-dd}.log.zip
</FileNamePattern>
</rollingPolicy>
<layoutclass="ch.qos.logback.classic.PatternLayout">
<Pattern>%d{yyyyMMdd-HH:mm:ss.SSSZ} [%thread] %-5level %logger.%method -%msg%n</Pattern>
</layout>
</appender>
<appender name="FILE_SIZE_ROLL"class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.dir}/${log.file}.log</file>
<Append>true</Append>
<Encoding>UTF-8</Encoding>
<BufferedIO>false</BufferedIO>
<BufferSize>8192</BufferSize>
<ImmediateFlush>true</ImmediateFlush>
<rollingPolicyclass="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
<FileNamePattern>
${log.dir}/bak/${log.file}-%i.log.zip
</FileNamePattern>
<MinIndex>0</MinIndex>
<MaxIndex>9</MaxIndex>
</rollingPolicy>
<triggeringPolicyclass="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<MaxFileSize>50MB</MaxFileSize>
</triggeringPolicy>
<layoutclass="ch.qos.logback.classic.PatternLayout">
<Pattern>%d{yyyyMMdd-HH:mm:ss.SSSZ} [%thread] %-5level %logger.%method -%msg%n</Pattern>
</layout>
</appender>
<root>
<level value="ALL" />
<appender-ref ref="STDOUT" />
<appender-ref ref="FILE_SIZE_ROLL"/>
</root>
<loggername="com.inforeach.util.log.Slf4jLogger">
<level value="DEBUG" />
</logger>
<logger name="org.logicalcobwebs.proxool">
<level value="DEBUG" />
</logger>
<logger name="testlogger.LoggerMain">
<level value="ALL" />
</logger>
</configuration>
In Eclipse Run Configuration ->Arguments ->VM set
-Dlogback.file.name=Test
5Run the application it should out put the resut in the out folder mentioned atthe top
Tip : Create a config folder in eclipse where you created the project and pass that folder in the build path
Place the logback.xml file in the config folder and pass that config folder as librabry from build path as add classpath
Steps to implement logging in core Java
1. Eclipse – include libraries ie logback-classic,core,access,slf4j-api.
2. Sample program
package testlogger;
import org.apache.log4j.PropertyConfigurator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.PatternLayout;
import ch.qos.logback.classic.spi.LoggingEvent;
import ch.qos.logback.core.FileAppender;
import ch.qos.logback.core.util.StatusPrinter;
public class LoggerMain {
private final Logger logger = LoggerFactory.getLogger(getClass());
public static void main(String[] args) {
// PropertyConfigurator.configure("log4j.properties");
new ConfigureLogBack();
LoggerMain lm = new LoggerMain();
lm.putLogger();
}
public void putLogger() {
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
StatusPrinter.print(lc);
logger.info("Hello");
}
}
1. In the classpath user librabries set the location of logback.xml
<configuration>
<substitutionProperty name="log.dir" value="D:\\logging\\" />
<substitutionProperty name="log.file" value="${logback.file.name<http://logback.file.name>}" />
- Show quoted text -
<appender name="STDOUT"
class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>%d{yyyyMMdd-HH:mm:ss.SSSZ} [%thread] %-5level %logger.%method - %msg%n</Pattern>
</layout>
</appender>
<appender name="STDOUT_inforeach" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>%date{HH:mm:ss.SSS} %level %msg%n</Pattern>
</layout>
</appender>
<appender name="FILE_DATE_ROLL"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.dir}/${log.file}.log</file>
<Append>true</Append>
<Encoding>UTF-8</Encoding>
<BufferedIO>false</BufferedIO>
<BufferSize>8192</BufferSize>
<ImmediateFlush>true</ImmediateFlush>
<rollingPolicy
class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<FileNamePattern>
${log.dir}/bak/${log.file}-%d{yyyy-MM-dd}.log.zip
</FileNamePattern>
</rollingPolicy>
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>%d{yyyyMMdd-HH:mm:ss.SSSZ} [%thread] %-5level %logger.%method - %msg%n</Pattern>
</layout>
</appender>
<appender name="FILE_SIZE_ROLL" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.dir}/${log.file}.log</file>
<Append>true</Append>
<Encoding>UTF-8</Encoding>
<BufferedIO>false</BufferedIO>
<BufferSize>8192</BufferSize>
<ImmediateFlush>true</ImmediateFlush>
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
<FileNamePattern>
${log.dir}/bak/${log.file}-%i.log.zip
</FileNamePattern>
<MinIndex>0</MinIndex>
<MaxIndex>9</MaxIndex>
</rollingPolicy>
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<MaxFileSize>50MB</MaxFileSize>
</triggeringPolicy>
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>%d{yyyyMMdd-HH:mm:ss.SSSZ} [%thread] %-5level %logger.%method - %msg%n</Pattern>
</layout>
</appender>
<root>
<level value="ALL" />
<appender-ref ref="STDOUT" />
<appender-ref ref="FILE_SIZE_ROLL" />
</root>
<logger name="com.inforeach.util.log.Slf4jLogger">
<level value="DEBUG" />
</logger>
<logger name="org.logicalcobwebs.proxool">
<level value="DEBUG" />
</logger>
<logger name="testlogger.LoggerMain">
<level value="ALL" />
</logger>
</configuration>
1. In Eclipse Run Configuration ->Arguments ->VM set
-Dlogback.file.name<http://Dlogback.file.name>=Test
5 Run the application it should out put the resut in the out folder mentioned at the top
Eclipse – include libraries ie logback-classic,core,access,slf4j-api.
Sample program
package testlogger;
import org.apache.log4j.PropertyConfigurator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.PatternLayout;
import ch.qos.logback.classic.spi.LoggingEvent;
import ch.qos.logback.core.FileAppender;
import ch.qos.logback.core.util.StatusPrinter;
public class LoggerMain {
private final Logger logger =LoggerFactory.getLogger(getClass());
public static void main(String[]args) {
// PropertyConfigurator.configure("log4j.properties");
newConfigureLogBack();
LoggerMainlm = new LoggerMain();
lm.putLogger();
}
public void putLogger() {
LoggerContextlc = (LoggerContext) LoggerFactory.getILoggerFactory();
StatusPrinter.print(lc);
logger.info("Hello");
}
}
In the classpath user librabries set the location of logback.xml
<configuration>
<substitutionProperty name="log.dir"value="D:\\logging\\" />
<substitutionProperty name="log.file"value="${logback.file.name}" />
<appender name="STDOUT"
class="ch.qos.logback.core.ConsoleAppender">
<layoutclass="ch.qos.logback.classic.PatternLayout">
<Pattern>%d{yyyyMMdd-HH:mm:ss.SSSZ} [%thread] %-5level %logger.%method -%msg%n</Pattern>
</layout>
</appender>
<appender name="STDOUT_inforeach"class="ch.qos.logback.core.ConsoleAppender">
<layoutclass="ch.qos.logback.classic.PatternLayout">
<Pattern>%date{HH:mm:ss.SSS} %level %msg%n</Pattern>
</layout>
</appender>
<appender name="FILE_DATE_ROLL"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.dir}/${log.file}.log</file>
<Append>true</Append>
<Encoding>UTF-8</Encoding>
<BufferedIO>false</BufferedIO>
<BufferSize>8192</BufferSize>
<ImmediateFlush>true</ImmediateFlush>
<rollingPolicy
class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<FileNamePattern>
${log.dir}/bak/${log.file}-%d{yyyy-MM-dd}.log.zip
</FileNamePattern>
</rollingPolicy>
<layoutclass="ch.qos.logback.classic.PatternLayout">
<Pattern>%d{yyyyMMdd-HH:mm:ss.SSSZ} [%thread] %-5level %logger.%method -%msg%n</Pattern>
</layout>
</appender>
<appender name="FILE_SIZE_ROLL"class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.dir}/${log.file}.log</file>
<Append>true</Append>
<Encoding>UTF-8</Encoding>
<BufferedIO>false</BufferedIO>
<BufferSize>8192</BufferSize>
<ImmediateFlush>true</ImmediateFlush>
<rollingPolicyclass="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
<FileNamePattern>
${log.dir}/bak/${log.file}-%i.log.zip
</FileNamePattern>
<MinIndex>0</MinIndex>
<MaxIndex>9</MaxIndex>
</rollingPolicy>
<triggeringPolicyclass="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<MaxFileSize>50MB</MaxFileSize>
</triggeringPolicy>
<layoutclass="ch.qos.logback.classic.PatternLayout">
<Pattern>%d{yyyyMMdd-HH:mm:ss.SSSZ} [%thread] %-5level %logger.%method -%msg%n</Pattern>
</layout>
</appender>
<root>
<level value="ALL" />
<appender-ref ref="STDOUT" />
<appender-ref ref="FILE_SIZE_ROLL"/>
</root>
<loggername="com.inforeach.util.log.Slf4jLogger">
<level value="DEBUG" />
</logger>
<logger name="org.logicalcobwebs.proxool">
<level value="DEBUG" />
</logger>
<logger name="testlogger.LoggerMain">
<level value="ALL" />
</logger>
</configuration>
In Eclipse Run Configuration ->Arguments ->VM set
-Dlogback.file.name=Test
5Run the application it should out put the resut in the out folder mentioned atthe top
Jars needed
logback-classic-0.9.8.jar
logback-core-0.9.8.jar
slf4j-api-1.4.3.jar
jcl104-over-slf4j-1.4.3.jar
logback-access-0.9.8.jar
Place the logback.xml file in the config folder and pass that config folder as librabry from build path as add classpath- Show quoted text -
On Tue, Feb 23, 2010 at 3:32 AM, Harshal Shah <harshals@synechron.com> wrote:
Steps to implement logging in core Java
Eclipse – include libraries ie logback-classic,core,access,slf4j-api.
Sample program
package testlogger;
import org.apache.log4j.PropertyConfigurator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.PatternLayout;
import ch.qos.logback.classic.spi.LoggingEvent;
import ch.qos.logback.core.FileAppender;
import ch.qos.logback.core.util.StatusPrinter;
public class LoggerMain {
private final Logger logger =LoggerFactory.getLogger(getClass());
public static void main(String[]args) {
// PropertyConfigurator.configure("log4j.properties");
newConfigureLogBack();
LoggerMainlm = new LoggerMain();
lm.putLogger();
}
public void putLogger() {
LoggerContextlc = (LoggerContext) LoggerFactory.getILoggerFactory();
StatusPrinter.print(lc);
logger.info("Hello");
}
}
In the classpath user librabries set the location of logback.xml
<configuration>
<substitutionProperty name="log.dir"value="D:\\logging\\" />
<substitutionProperty name="log.file"value="${logback.file.name}" />
<appender name="STDOUT"
class="ch.qos.logback.core.ConsoleAppender">
<layoutclass="ch.qos.logback.classic.PatternLayout">
<Pattern>%d{yyyyMMdd-HH:mm:ss.SSSZ} [%thread] %-5level %logger.%method -%msg%n</Pattern>
</layout>
</appender>
<appender name="STDOUT_inforeach"class="ch.qos.logback.core.ConsoleAppender">
<layoutclass="ch.qos.logback.classic.PatternLayout">
<Pattern>%date{HH:mm:ss.SSS} %level %msg%n</Pattern>
</layout>
</appender>
<appender name="FILE_DATE_ROLL"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.dir}/${log.file}.log</file>
<Append>true</Append>
<Encoding>UTF-8</Encoding>
<BufferedIO>false</BufferedIO>
<BufferSize>8192</BufferSize>
<ImmediateFlush>true</ImmediateFlush>
<rollingPolicy
class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<FileNamePattern>
${log.dir}/bak/${log.file}-%d{yyyy-MM-dd}.log.zip
</FileNamePattern>
</rollingPolicy>
<layoutclass="ch.qos.logback.classic.PatternLayout">
<Pattern>%d{yyyyMMdd-HH:mm:ss.SSSZ} [%thread] %-5level %logger.%method -%msg%n</Pattern>
</layout>
</appender>
<appender name="FILE_SIZE_ROLL"class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.dir}/${log.file}.log</file>
<Append>true</Append>
<Encoding>UTF-8</Encoding>
<BufferedIO>false</BufferedIO>
<BufferSize>8192</BufferSize>
<ImmediateFlush>true</ImmediateFlush>
<rollingPolicyclass="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
<FileNamePattern>
${log.dir}/bak/${log.file}-%i.log.zip
</FileNamePattern>
<MinIndex>0</MinIndex>
<MaxIndex>9</MaxIndex>
</rollingPolicy>
<triggeringPolicyclass="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<MaxFileSize>50MB</MaxFileSize>
</triggeringPolicy>
<layoutclass="ch.qos.logback.classic.PatternLayout">
<Pattern>%d{yyyyMMdd-HH:mm:ss.SSSZ} [%thread] %-5level %logger.%method -%msg%n</Pattern>
</layout>
</appender>
<root>
<level value="ALL" />
<appender-ref ref="STDOUT" />
<appender-ref ref="FILE_SIZE_ROLL"/>
</root>
<loggername="com.inforeach.util.log.Slf4jLogger">
<level value="DEBUG" />
</logger>
<logger name="org.logicalcobwebs.proxool">
<level value="DEBUG" />
</logger>
<logger name="testlogger.LoggerMain">
<level value="ALL" />
</logger>
</configuration>
In Eclipse Run Configuration ->Arguments ->VM set
-Dlogback.file.name=Test
5Run the application it should out put the resut in the out folder mentioned atthe top
Tip : Create a config folder in eclipse where you created the project and pass that folder in the build path
Place the logback.xml file in the config folder and pass that config folder as librabry from build path as add classpath
Steps to implement logging in core Java
1. Eclipse – include libraries ie logback-classic,core,access,slf4j-api.
2. Sample program
package testlogger;
import org.apache.log4j.PropertyConfigurator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.PatternLayout;
import ch.qos.logback.classic.spi.LoggingEvent;
import ch.qos.logback.core.FileAppender;
import ch.qos.logback.core.util.StatusPrinter;
public class LoggerMain {
private final Logger logger = LoggerFactory.getLogger(getClass());
public static void main(String[] args) {
// PropertyConfigurator.configure("log4j.properties");
new ConfigureLogBack();
LoggerMain lm = new LoggerMain();
lm.putLogger();
}
public void putLogger() {
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
StatusPrinter.print(lc);
logger.info("Hello");
}
}
1. In the classpath user librabries set the location of logback.xml
<configuration>
<substitutionProperty name="log.dir" value="D:\\logging\\" />
<substitutionProperty name="log.file" value="${logback.file.name<http://logback.file.name>}" />
- Show quoted text -
<appender name="STDOUT"
class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>%d{yyyyMMdd-HH:mm:ss.SSSZ} [%thread] %-5level %logger.%method - %msg%n</Pattern>
</layout>
</appender>
<appender name="STDOUT_inforeach" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>%date{HH:mm:ss.SSS} %level %msg%n</Pattern>
</layout>
</appender>
<appender name="FILE_DATE_ROLL"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.dir}/${log.file}.log</file>
<Append>true</Append>
<Encoding>UTF-8</Encoding>
<BufferedIO>false</BufferedIO>
<BufferSize>8192</BufferSize>
<ImmediateFlush>true</ImmediateFlush>
<rollingPolicy
class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<FileNamePattern>
${log.dir}/bak/${log.file}-%d{yyyy-MM-dd}.log.zip
</FileNamePattern>
</rollingPolicy>
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>%d{yyyyMMdd-HH:mm:ss.SSSZ} [%thread] %-5level %logger.%method - %msg%n</Pattern>
</layout>
</appender>
<appender name="FILE_SIZE_ROLL" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.dir}/${log.file}.log</file>
<Append>true</Append>
<Encoding>UTF-8</Encoding>
<BufferedIO>false</BufferedIO>
<BufferSize>8192</BufferSize>
<ImmediateFlush>true</ImmediateFlush>
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
<FileNamePattern>
${log.dir}/bak/${log.file}-%i.log.zip
</FileNamePattern>
<MinIndex>0</MinIndex>
<MaxIndex>9</MaxIndex>
</rollingPolicy>
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<MaxFileSize>50MB</MaxFileSize>
</triggeringPolicy>
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>%d{yyyyMMdd-HH:mm:ss.SSSZ} [%thread] %-5level %logger.%method - %msg%n</Pattern>
</layout>
</appender>
<root>
<level value="ALL" />
<appender-ref ref="STDOUT" />
<appender-ref ref="FILE_SIZE_ROLL" />
</root>
<logger name="com.inforeach.util.log.Slf4jLogger">
<level value="DEBUG" />
</logger>
<logger name="org.logicalcobwebs.proxool">
<level value="DEBUG" />
</logger>
<logger name="testlogger.LoggerMain">
<level value="ALL" />
</logger>
</configuration>
1. In Eclipse Run Configuration ->Arguments ->VM set
-Dlogback.file.name<http://Dlogback.file.name>=Test
5 Run the application it should out put the resut in the out folder mentioned at the top
No comments:
Post a Comment