Files
@ 719e5d2dc018
Branch filter:
Location: libtransport.git/docs/guide/logging.textile
719e5d2dc018
5.6 KiB
text/plain
build on the mac
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | Spectrum 2 uses "log4cxx":http://logging.apache.org/log4cxx/ for logging. In the main config file, there are two options to set full path to log4cxx configuration files which are then used for backends and Spectrum 2 main instance:
<pre>
[logging]
# Full path to config file used for main Spectrum 2 instance logging
config=/etc/spectrum2/logging.cfg
# Full path to config file used for backends logging
backend_config=/etc/spectrum2/backend-logging.cfg
</pre>
h2. Log4cxx config files
There is full "documentation of log4cxx on log4cxx homepage":http://logging.apache.org/log4cxx/index.html.
h3. Logging everything to stdout
For logging to stdout, we have to use ConsoleAppender appender like this:
<pre>
# We create two rootLoggers:
# - "debug" is internal logger used by log4cxx
# - "stdout" is name of our ConsoleAppender logger
log4j.rootLogger=debug, stdout
# Create new ConsoleAppender logger with custom PatternLayout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
# Define the output pattern. Characters are mentioned here: http://logging.apache.org/log4cxx/apidocs/classlog4cxx_1_1_pattern_layout.html
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d %-5p %c: %m%n
</pre>
Configuration options for ConversationPattern are described "here":http://logging.apache.org/log4cxx/apidocs/classlog4cxx_1_1_pattern_layout.html
h3. Logging everything to file
<pre>
# We create two rootLoggers
# - "debug" is internal logger used by log4cxx
# - "R" is name of our RollingFileAppender logger
log4j.rootLogger=debug, R
# Create new RollingFileAppender logger
log4j.appender.R=org.apache.log4j.RollingFileAppender
# Set the filename
log4j.appender.R.File=/var/log/spectrum2/${jid}/spectrum2.log
# Set MaxFileSize. Log will be rotated automatically when this limit is reached
log4j.appender.R.MaxFileSize=10000KB
# Keep one backup file
log4j.appender.R.MaxBackupIndex=1
# Define the output pattern. Characters are mentioned here: http://logging.apache.org/log4cxx/apidocs/classlog4cxx_1_1_pattern_layout.html
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%d %-5p %c: %m%n
</pre>
h3. Logging XML to different file
We have to create another RollingFileAppender to achive this:
<pre>
# We create two rootLoggers
# - "debug" is internal logger used by log4cxx
# - "R" is name of our RollingFileAppender logger for everything except XML
log4j.rootLogger=debug, R
# ---- spectrum2.log
# Create new RollingFileAppender logger
log4j.appender.R=org.apache.log4j.RollingFileAppender
# Set the filename
log4j.appender.R.File=/var/log/spectrum2/${jid}/spectrum2.log
# Set MaxFileSize. Log will be rotated automatically when this limit is reached
log4j.appender.R.MaxFileSize=10000KB
# Keep one backup file
log4j.appender.R.MaxBackupIndex=1
# Define the output pattern. Characters are mentioned here: http://logging.apache.org/log4cxx/apidocs/classlog4cxx_1_1_pattern_layout.html
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%d %-5p %c: %m%n
# ---- spectrum2_xml.log
# Define new logger for category Component.XML:
# - "debug" is internal logger used by log4cxx
# - "XML" is the name of our RollingFileAppender logger for XML category
log4j.category.Component.XML = debug, XML
# Do not add XML category into "R" logger, so XML category will be logged only to spectrum2_xml.log, but not to spectrum2.log.
# If you want to have XML category also in spectrum2.log, set this value to "true"
log4j.additivity.Component.XML=false
# Create new RollingFileAppender logger and set the file name
log4j.appender.XML=org.apache.log4j.RollingFileAppender
log4j.appender.XML.File=/var/log/spectrum2/${jid}/spectrum2_xml.log
# Set MaxFileSize. Log will be rotated automatically when this limit is reached
log4j.appender.XML.MaxFileSize=100000KB
# Keep one backup file
log4j.appender.XML.MaxBackupIndex=4
# Define the output pattern. Characters are mentioned here: http://logging.apache.org/log4cxx/apidocs/classlog4cxx_1_1_pattern_layout.html
log4j.appender.XML.layout=org.apache.log4j.PatternLayout
log4j.appender.XML.layout.ConversionPattern=%d %-5p %c: %m%n
</pre>
h3. Disable XML logging
<pre>
# We create two rootLoggers:
# - "debug" is internal logger used by log4cxx
# - "stdout" is name of our ConsoleAppender logger
log4j.rootLogger=debug, stdout
# Create new ConsoleAppender logger with custom PatternLayout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
# Define the output pattern. Characters are mentioned here: http://logging.apache.org/log4cxx/apidocs/classlog4cxx_1_1_pattern_layout.html
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d %-5p %c: %m%n
# Disable XML category
log4j.category.Component.XML = OFF
</pre>
h3. Disable logging
To disable logging, you still *must have* one logger created (probably the ConsoleAppender), but you can set log4j.threshold = OFF to not log everything later:
<pre>
# We create two rootLoggers:
# - "debug" is internal logger used by log4cxx
# - "stdout" is name of our ConsoleAppender logger
log4j.rootLogger=debug, stdout
# Create new ConsoleAppender logger with custom PatternLayout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
# Define the output pattern. Characters are mentioned here: http://logging.apache.org/log4cxx/apidocs/classlog4cxx_1_1_pattern_layout.html
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d %-5p %c: %m%n
# Disable logging of everything:
log4j.threshold = OFF
</pre>
|