Cookie Consent by SimpleLogger
Simple-logger for Java. Because it's simple.
Simple-logger is a Java library for writing log files. It doesn't need any configuration files. All parameters can be set directly from the code. Simple-logger provides standard logging levels: TRACE, DEBUG, INFO, WARN, ERROR and FATAL. Simple-logger supports also file-rolling policy; max file size and number of backups are configurable.
Simple-logger is written in Java and should run on all systems with JRE 1.4 or above installed.
Current version: 1.6.4
Quick start
Start using simple-logger by simply creating new SimpleLogger object:
SimpleLogger logger = new SimpleLogger();
At least path to log file should be set, otherwise simple-logger will write into default log file (called simple-logger.log inside working directory):
Now you are ready to log the first line:"Hello simple-logger!");
Logging levels
The method names for writing to log files are similar to other logger implementations, so the implementation library can easily be switched to simple-logger.
simple-logger supports six levels of logging:
trace(String s)
debug(String s)
info(String s)
warn(String s)
error(String s)
fatal(String s)
All above methods for logging also accept additional argument 'Throwable', which will write the whole exception stack trace to log file. Eg. logger.error(String s, Throwable t).
Logger parameters can be set inline inside Java code. simple-logger supports the following methods for configuration:
Set path and name of log file. Eg: /path/to/log/file/mylog.log
Default value is ./simple-logger.log
setFilename(String filename)
Set true to append text to existing log file. If set to false, log file will be overwritten and started from the scratch.
Default value is true.
setAppend(boolean append)
Set logging level. Logging levels are defined in LEVEL class: TRACE, DEBUG, INFO, WARN, ERROR and FATAL
Default value is LEVEL.INFO.
setLogLevel(int level)
Set java specific date format. Eg. format yyyy.MM.dd hh:mm:ss:SSS gives year, month, day, hour, minutes, seconds and milliseconds.
Default value is yyyy.MM.dd hh:mm:ss:SSS
setDateFormat(String format)
Set maximum size of log file in megabytes. When the limit is reached new log file is opened and logging continues. Previous log file gets .1 suffix.
Default value is 10.
setMaxSizeMb(int maxSizeMb)
Set number of rolling log files. When max file size of active log file is reached, it is renamed to filename.1, and filename.1 is renamed to filename.2 an so on... The number of last backup log files is defined with backup parameter.
Default value is 5.
setBackup(int backup)
Enable 'System.out.println' option.
Default value false (disabled).
setVerbose(boolean verbose)
Alternatively configure simple-logger with properties file. Here are the parameters:
simplelogger.dateFormat=yyyy.MM.dd hh:mm:ss:SSS

Visitors: 5661