source: gs3-extensions/maori-lang-detection/conf/log4j.properties@ 33615

Last change on this file since 33615 was 33615, checked in by ak19, 4 years ago
  1. Worked out how to configure log4j to log both to console and logfile, so modified the existing laboured code to use this better way. 2. Added some Mongodb links under MoreReading.
File size: 2.6 KB
Line 
1# See for basic example https://stackoverflow.com/questions/125 32339/no-appenders-could-be-found-for-loggerlog4j
2# For better examples, see /greenstone/greenstone3/web/WEB-INF/classes/log4j.properties
3# Manual (examples use XML versions of log4j config files): https://logging.apache.org/log4j/2.x/manual/configuration.html
4# https://logging.apache.org/log4j/2.x/manual/configuration.html#Properties
5# HH (0-24 hrs) vs hh (0-12 hrs, am/pm): https://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html
6# https://logging.apache.org/log4j/1.2/manual.html
7#######################
8
9# define some reusable properties
10maori-lang-detector.home=/Scratch/ak19/gs3-extensions/maori-lang-detection
11maori-lang-detector.logpath=${maori-lang-detector.home}/logs
12
13# Let's log everything from the most basic DEBUG msgs on (so INFO, WARN, ERROR too)
14# Also want to log to the console, see
15# https://stackoverflow.com/questions/3382985/how-to-make-log4j-to-write-to-the-console-as-well
16
17log4j.rootCategory=DEBUG, console, mldlog
18
19# Define Console Appender
20log4j.appender.console=org.apache.log4j.ConsoleAppender
21# Define the layout for console appender. If you do not define it, you will get an error
22log4j.appender.console.layout=org.apache.log4j.PatternLayout
23log4j.appender.console.Target=System.err
24
25# We're saying our log "mldlog" is some file that gets appended to,
26# and it will write it out to "maori-lang-detector.log" located in whatever we defined the "logpath" to be
27
28# Old way of logging:
29#log4j.appender.mldlog=org.apache.log4j.RollingFileAppender
30#log4j.appender.mldlog.File=${maori-lang-detector.logpath}/maori-lang-detector.log
31## https://howtodoinjava.com/log4j/log4j-rolling-file-appender/
32##log4j.appender.mldlog.MaxBackupIndex=10
33
34# We want a DailyRollingFileAppender.
35# Its behaviour is explained at
36# https://examples.javacodegeeks.com/enterprise-java/log4j/log4j-rolling-daily-file-example/
37log4j.appender.mldlog=org.apache.log4j.DailyRollingFileAppender
38log4j.appender.mldlog.File=${maori-lang-detector.logpath}/maori-lang-detector.log
39log4j.appender.mldlog.DatePattern='.'yyyy-MM-dd
40 # set to roll over every day, can change this to weekly/every min etc, see https://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/DailyRollingFileAppender.html
41
42# if you have more logs, define category, additivity, appender and appender.File for it as above
43# for each log also set the format of the output as below, after setting the layout to use PatternLayout class to parse the format
44
45log4j.appender.mldlog.layout=org.apache.log4j.PatternLayout
46log4j.appender.mldlog.layout.ConversionPattern=%-5p: [%d{yyyy-MM-dd HH:mm:ss}] %C{1}.%M()%n %m%n
47
48#######################
Note: See TracBrowser for help on using the repository browser.