Cookie Consent by PrivacyPolicies.com SimpleLogger
Simple-logger for Java. Because it's simple.
About
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.
Download
Current version: 1.6.4
simple-logger-1.6.4.zip
Github
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):
logger.setFilename("/path/to/log/custom-name.log");
Now you are ready to log the first line:
logger.info("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).
Configuration
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.filename=./simple-logger.log
simplelogger.level=INFO
simplelogger.append=true
simplelogger.verbose=false
simplelogger.maxFileSize=1
simplelogger.maxBackupFiles=2
simplelogger.dateFormat=yyyy.MM.dd hh:mm:ss:SSS
		
www.matjazcerkvenik.si

Visitors: 6024