Jar file needed:
log4j-1.2.17 or newer
Configuration of Logger (log4j.xml)
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration debug="true"
xmlns:log4j='http://jakarta.apache.org/log4j/'>
<appender name="consoleAppender" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{dd MMM yyyy HH:mm:ss} %5p %c{1} - %m%n"/>
</layout>
</appender>
<appender name="fileAppender" class="org.apache.log4j.RollingFileAppender">
<param name="append" value="true"/>
<param name="file" value="log/pushLog.log"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{dd MMM yyyy HH:mm:ss} %5p %c{1} - %m%n"/>
</layout>
</appender>
<root>
<level value="INFO"/>
<appender-ref ref="consoleAppender"/>
<appender-ref ref="fileAppender"/>
</root>
</log4j:configuration>
Java class
import org.apache.log4j.Logger;
public class SampleLogger {
private static final Logger m_log = Logger.getLogger(SampleLogger.class);
public static void main(String arg[])
{
m_log.info("Application start...");
try{
// your code
}catch(Exception e)
{
m_log.info("Exception occured...");
m_log.info(e.getMessage());
}
m_log.info("Application End...");
}
}
log4j-1.2.17 or newer
Configuration of Logger (log4j.xml)
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration debug="true"
xmlns:log4j='http://jakarta.apache.org/log4j/'>
<appender name="consoleAppender" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{dd MMM yyyy HH:mm:ss} %5p %c{1} - %m%n"/>
</layout>
</appender>
<appender name="fileAppender" class="org.apache.log4j.RollingFileAppender">
<param name="append" value="true"/>
<param name="file" value="log/pushLog.log"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{dd MMM yyyy HH:mm:ss} %5p %c{1} - %m%n"/>
</layout>
</appender>
<root>
<level value="INFO"/>
<appender-ref ref="consoleAppender"/>
<appender-ref ref="fileAppender"/>
</root>
</log4j:configuration>
Java class
import org.apache.log4j.Logger;
public class SampleLogger {
private static final Logger m_log = Logger.getLogger(SampleLogger.class);
public static void main(String arg[])
{
m_log.info("Application start...");
try{
// your code
}catch(Exception e)
{
m_log.info("Exception occured...");
m_log.info(e.getMessage());
}
m_log.info("Application End...");
}
}
Everything is very open with a precise explanation of the challenges.
ReplyDeleteIt was definitely informative. Your website is very useful.
Many thanks for sharing!
Feel free to surf to my webpage ... garcinia cambogia select where to buy
I hardly leave responses, but after reading through
ReplyDeletea few of the comments on this page "site to shrink url http://adf.ly/3wJT9".
I do have 2 questions for you if you don't mind. Is it just me or do some of these remarks come across like they are coming from brain dead people?
:-P And, if you are writing on other places, I'd like to follow
anything new you have to post. Would you make a list of every
one of all your social sites like your twitter feed, Facebook
page or linkedin profile?
Here is my weblog buy garcinia cambogia select; ,