Simple Log was written out of frustration with other "logging frameworks". Many of its features are designed to contrast with the way in which these frameworks are used. Because of this, it seemed sensible to show a comparison between Simple Log and one of these frameworks so that you can see the difference before committing to using Simple Log in your own code. I have chosen Log4J for the comparison, as this is undoubtedly the most widely used logging framework.
这个log软件很简单,只有三个class.
半个小时就可以基本学会使用。
https://simple-log.dev.java.net/
tips:
Creating a Logger
private static final SimpleLogger log = new SimpleLogger(Test.class);
Given no configuration file, Simple Log produces no output. This is a feature that allows you to easily have zero output in deployment if desired.
The default output of a Simple Log text log message is shown below.Thu 2006/02/09 08:38:11.269| |main|Test|Plain message
Type of Output
log.entry("main()");
log.info("Plain message");
log.infoObject("object", new Object());
log.errorException(new Exception("Test Exception"));
log.exit("main()");
Above is the code used to produce the below output.Thu 2006/02/09 08:38:11.269|>>>|main|Test|main() Thu 2006/02/09 08:38:11.269| |main|Test|Plain message Thu 2006/02/09 08:38:11.269|---|main|Test|object|java.lang.Object@bf2d5e Thu 2006/02/09 08:38:11.269|***|main|Test|java.lang.Exception: Test Exception java.lang.Exception: Test Exception at test.Test.main(Test.java:52) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90) Thu 2006/02/09 08:38:11.279|<<<|main|Test|main()
Logging to a File
To log to a file using Simple Log, simply specify the name of the file with the simplelog.logFile
property.simplelog.logFile = application.log
Log File Rolling
simplelog.logFile=application.log
simplelog.rollover=timeOfDay
simplelog.rollover.timeOfDay.time=02:00
simplelog.rollover.timeOfDay.timezone=GMT+10:00
Instance-Based Logging
public class TreeNode {
private final SimpleLogger log;
public TreeNode(String name) {
log = new SimpleLogger(TreeNode.class, name);
}
}