Gretty protocols it’s own messages and messages from servlet container with the help of logback-classic library.
Gretty isolates it’s own logging from the web application logging on the level of ClassLoader. That means: the logback library (and logback configuration) used by Gretty is not visible within web application. You are free to use any logging system - logback, log4j, commons-logging etc. - within your web applications.
Gretty supports configuring it’s own slf4j/logback logging by two methods:
If you place "logback.groovy" or "logback.xml" to arbitrary folder and then reference it by logbackConfigFile property, gretty applies the specified configuration to servlet-container process.
If "logback.groovy" or "logback.xml" is not specified, gretty configures logging with default settings:
It enables slf4j logging with level INFO.
It configures two appenders: one for console and another for the log file.
Log file by default has name "${project.name}.log" and is created in folder "$HOME/logs".
You can fine-tune gretty logging by adjusting the following properties [of gretty plugin extension]:
logbackConfigFile defines the absolute or relative path to logback configuration file (.groovy or .xml). If "logbackConfigFile" is relative, it is first combined with projectDir. If the resulting path points to an existing file, it is used for logback configuration. If not, gretty tries to combine "logbackConfigFile" with directories "$projectDir/logback", "$projectDir/server", "$projectDir/config". If any resulting path points to an existing file, it is used for logback configuration.
loggingLevel defines slf4j logging-level for servlet-container process. It is a string, having one of the values: 'ALL', 'DEBUG', 'ERROR', 'INFO', 'OFF', 'TRACE', 'WARN'. The default value is 'INFO'.
consoleLogEnabled defines, whether log messages are written to the terminal. It is a boolean, default is "true".
fileLogEnabled defines, whether log messages are written to the log-file. It is a boolean, default is "true".
logFileName defines log file name (without path). It is a string, default value is "${project.name}.log".
logDir defines directory, where log file is created. It is a string, default value is "$HOME/logs".
Important
|
when logback configuration is groovy-based (not XML), Gretty injects other logging properties ("loggingLevel", "consoleLogEnabled", "fileLogEnabled", "logFileName", "logDir") are binding variables to the groovy configuration. |