logback grails log in different files
//grails-app/confg/logback.groovy
import grails.util.BuildSettings
import grails.util.Environment
import ch.qos.logback.core.rolling.RollingFileAppender
import ch.qos.logback.core.rolling.TimeBasedRollingPolicy
import ch.qos.logback.core.util.FileSize
def HOME_DIR = "."
// See http://logback.qos.ch/manual/groovy.html for details on configuration
appender('STDOUT', ConsoleAppender) {
encoder(PatternLayoutEncoder) {
pattern = "%level %logger - %msg%n"
}
}
appender("ROLLING", RollingFileAppender) {
encoder(PatternLayoutEncoder) {
pattern = "%level %logger - %msg%n"
}
rollingPolicy(TimeBasedRollingPolicy) {
fileNamePattern = "${HOME_DIR}/logs/myApp-%d{yyyy-MM-dd_HH-mm}.log"
maxHistory = 30
totalSizeCap = FileSize.valueOf("2GB")
}
}
def targetDir = BuildSettings.TARGET_DIR
if (Environment.isDevelopmentMode() && targetDir != null) {
appender("FULL_STACKTRACE", FileAppender) {
file = "${targetDir}/stacktrace.log"
append = true
encoder(PatternLayoutEncoder) {
pattern = "%level %logger - %msg%n"
}
}
logger("StackTrace", ERROR, ['FULL_STACKTRACE'], false)
root(ERROR, ['STDOUT', 'FULL_STACKTRACE'])
}
else {
root(ERROR, ['ROLLING'])
}
4
9
fileNamePattern = "/myApp-log.%d{yyyy/MM}.gz" //Rollover at the beginning of each month, compress the rolled-over file with GZIP
Thank you!
9
0
3.83
6
//grails-app/confg/logback.groovy
import ch.qos.logback.core.rolling.RollingFileAppender
import ch.qos.logback.core.rolling.TimeBasedRollingPolicy
import ch.qos.logback.core.util.FileSize
def HOME_DIR = "."
appender("ROLLING", RollingFileAppender) {
encoder(PatternLayoutEncoder) {
pattern = "%level %logger - %msg%n"
}
rollingPolicy(TimeBasedRollingPolicy) {
fileNamePattern = "${HOME_DIR}/logs/myApp-%d{yyyy-MM-dd_HH-mm}.log"
maxHistory = 30
totalSizeCap = FileSize.valueOf("2GB")
}
}
Thank you!
6
0
4.2
10
//grails-app/confg/logback.groovy
import grails.util.BuildSettings
import grails.util.Environment
// See http://logback.qos.ch/manual/groovy.html for details on configuration
appender('STDOUT', ConsoleAppender) {
encoder(PatternLayoutEncoder) {
pattern = "%level %logger - %msg%n"
}
}
def targetDir = BuildSettings.TARGET_DIR
if (Environment.isDevelopmentMode() && targetDir != null) {
appender("FULL_STACKTRACE", FileAppender) {
file = "${targetDir}/stacktrace.log"
append = true
encoder(PatternLayoutEncoder) {
pattern = "%level %logger - %msg%n"
}
}
logger("StackTrace", ERROR, ['FULL_STACKTRACE'], false)
root(ERROR, ['STDOUT', 'FULL_STACKTRACE'])
}
else {
root(ERROR, ['STDOUT'])
}
Thank you!
10
0
4
3
fileNamePattern = "/logs/%d{yyyy/MM}/myApp.log" //Rollover at the beginning of each month.
//Each log file will be stored in a year/month directory, e.g: /logs/2016/11/myApp.log, /logs/2016/12/myApp.log, /logs/2017/01/myApp.log
Thank you!
3
0
5
1
fileNamePattern = "/myApp-log.%d{yyyy-MM}.log" //Rollover at the beginning of each month, file format: myApp-log.2016-11.log
fileNamePattern = "/myApp-log.%d{yyyy-ww}.log" //Rollover at the first day of each week. Note that the first day of the week depends on the locale.
fileNamePattern = "/myApp-log.%d{yyyy-MM-dd_HH}.log" //Rollover at the top of each hour.
Thank you!
1
0
Are there any code examples left?
New code examples in category Ruby
-
Ruby 2022-03-27 13:25:03 ruby assign value to hash
-
Ruby 2022-03-25 04:05:10 test if array empty ruby
-
Ruby 2022-03-24 19:45:17 rails update without validation
-
Ruby 2022-03-23 05:15:08 ruby hello world
-
Ruby 2022-03-23 02:40:01 rails keep all params except for some
-
Ruby 2022-03-20 06:15:08 rails hidden field default value
-
Ruby 2022-03-19 19:55:31 print things ruby
-
Ruby 2022-03-18 22:15:07 rails command line
-
Ruby 2022-03-18 08:10:03 ruby get the number of same element in array
-
Ruby 2022-03-17 02:40:17 drop rails all db