logback-dev
Threads by month
- ----- 2025 -----
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
March 2010
- 11 participants
- 188 discussions

[JIRA] Created: (LBCLASSIC-190) Allow programmatic traversal of the logger tree
by Robert Elliot (JIRA) 08 Mar '10
by Robert Elliot (JIRA) 08 Mar '10
08 Mar '10
Allow programmatic traversal of the logger tree
-----------------------------------------------
Key: LBCLASSIC-190
URL: http://jira.qos.ch/browse/LBCLASSIC-190
Project: logback-classic
Issue Type: Improvement
Components: Other
Affects Versions: 0.9.19
Reporter: Robert Elliot
Assignee: Logback dev list
I'm interested in writing a module for logback to allow on the fly changes to the logger tree - changing levels, adding appenders, maybe adding filters with code supplied dynamically. My vision for the gui is to show the logger tree like a folder tree.
However, now I come to look at it it seems neither the child loggers nor the parent logger of a logger are exposed, which rather blows this whole concept out of the water.
Is there a particularly strong reason for this? If not, I've forked logback here:
http://github.com/Mahoney/logback
and exposed the data. As part of the same thing I changed the children from a List to a Set as it seems more semantically correct and cleans up the code slightly.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.qos.ch/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
2
3

[JIRA] Created: (CONSPLUG-23) double-click on console log message doesn't open editor when message came from an inner class
by Joe Kearney (JIRA) 08 Mar '10
by Joe Kearney (JIRA) 08 Mar '10
08 Mar '10
double-click on console log message doesn't open editor when message came from an inner class
---------------------------------------------------------------------------------------------
Key: CONSPLUG-23
URL: http://jira.qos.ch/browse/CONSPLUG-23
Project: Console Plugin
Issue Type: Bug
Environment: Eclipse 3.5.2, Logback console 1.1.0, logback 0.9.0, slf4j 1.5.11
Reporter: Joe Kearney
Assignee: Logback dev list
Example below. All three log messages are logged, but only the first goes to the log statement on double click.
{code:title=Scratch.java}
package logback.console.bug.demo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class Scratch {
private static final Logger LOGGER = LoggerFactory.getLogger(Scratch.class.getName());
public static void main(String[] args) {
LOGGER.info("hello from main()");
new InnerClass().someMethod();
}
private static class InnerClass {
private static final Logger LOCAL_LOGGER = LoggerFactory.getLogger(Scratch.InnerClass.class.getName());
public void someMethod() {
LOGGER.info("Hello from inner class through outer logger");
LOCAL_LOGGER.info("Hello from inner class through inner logger");
}
}
}
{code}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.qos.ch/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
1
0

08 Mar '10
Review the logack-demo chapter
------------------------------
Key: LBSITE-39
URL: http://jira.qos.ch/browse/LBSITE-39
Project: logback-site
Issue Type: Task
Reporter: Ceki Gulcu
Assignee: Logback dev list
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.qos.ch/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
1
0

[JIRA] Created: (CONSPLUG-22) autocomplete in filter creation dialog
by Joe Kearney (JIRA) 08 Mar '10
by Joe Kearney (JIRA) 08 Mar '10
08 Mar '10
autocomplete in filter creation dialog
--------------------------------------
Key: CONSPLUG-22
URL: http://jira.qos.ch/browse/CONSPLUG-22
Project: Console Plugin
Issue Type: New Feature
Components: interface
Reporter: Joe Kearney
Assignee: Logback dev list
Priority: Minor
It would very useful to be able to use autocomplete in creating filter expressions. This would mean a user doesn't need to know the logback API. Could perhaps present the built-in variables (documentation page talks about "level, logger, message, and several others") initially.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.qos.ch/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
1
0

[JIRA] Created: (CONSPLUG-21) filtering by logger name is disallowed by filter entry dialog
by Joe Kearney (JIRA) 08 Mar '10
by Joe Kearney (JIRA) 08 Mar '10
08 Mar '10
filtering by logger name is disallowed by filter entry dialog
-------------------------------------------------------------
Key: CONSPLUG-21
URL: http://jira.qos.ch/browse/CONSPLUG-21
Project: Console Plugin
Issue Type: Bug
Environment: Eclipse 3.5.2, console plugin 1.1
Reporter: Joe Kearney
Assignee: Logback dev list
Filtering by logger name doesn't appear to work. Dialog says "The new expression is not correct." for a number of filter expressions that seem correctly formed.
Example use case: I'm trying to filter to accept DEBUG messages from my code, but deny such messages from Spring, whose loggers are called "org.springframework...".
Example reproduction: I try the following and keep getting "The new expression is not correct." There is no error in the Eclipse error log or in the console.
logger.contains("org.springframework")
event.getLoggerName().contains("org.springframework")
(Guessing types of these supplied variables from http://logback.qos.ch/manual/filters.html#evalutatorFilter.)
Filtering on the message appears to be accepted by the config window:
message.contains("org.springframework")
but it doesn't apply any filtering to the logger name. (Here the logger name actually gets compacted to "o.s...." but trying other, non-compacted, segments of the name doesn't help either.) I assume that this is intended behaviour.
For now I can filter out things like "reating instance" or "bean", but that's hardly satisfactory. Some more examples in the plugin documentation would be mighty handy.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.qos.ch/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
1
0

08 Mar '10
[ http://jira.qos.ch/browse/LBCLASSIC-57?page=com.atlassian.jira.plugin.syste… ]
Ceki Gulcu commented on LBCLASSIC-57:
-------------------------------------
The bug has been fixed by SyslogAppender truncating messages longer than 256Kbytes.
> SyslogAppender fails sporadically
> ---------------------------------
>
> Key: LBCLASSIC-57
> URL: http://jira.qos.ch/browse/LBCLASSIC-57
> Project: logback-classic
> Issue Type: Bug
> Environment: $ uname -a
> Linux ... 2.6.9-67.ELsmp #1 SMP Wed Nov 7 13:56:44 EST 2007 x86_64 x86_64 x86_64 GNU/Linux
> $ java -version
> java version "1.6.0_03"
> Java(TM) SE Runtime Environment (build 1.6.0_03-b05)
> Java HotSpot(TM) Server VM (build 1.6.0_03-b05, mixed mode)
> multiprocessor PC box
> Reporter: Anton Tagunov
> Assignee: Logback dev list
> Fix For: 0.9.12
>
>
> * several JVM-s per Linux box
> * 5 SyslogAppender-s logging to syslog-ng on 127.0.0.1
> Once in a while one of the SyslogAppender-s (the busiest one with longest messages) stops logging completely
> Other SyslogAppender-ss continue working fine.
> /usr/sbin/tcpdump has confirmed upd packets reach
> syslog-ng port via 'lo' network interface for remaining appends
> /usr/sbin/tcpdump has confirmed NO udp packets reach
> syslog-ng port via 'lo' network interface for the failing appender
> We have JMX enabled. JConsole does show StatusManager messages.
> There are no error messages there.
> Just the messages emitted during initial logback configuration
> from logback.xml on the classpath.
> We had invoked 'reload()' method via JMX.
> StatusMananger messages observed via JMX show that reload had happened.
> Full re-configuration had happened.
> All 5 SyslogAppenders had been apparently re-created.
> Yet NO udp messages had come from the SyslogAppender
> replacing those which had previously failed.
> Reloading did not help at all.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.qos.ch/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
1
0

[JIRA] Commented: (LBCLASSIC-57) SyslogAppender fails sporadically
by Ingo Siebert (JIRA) 08 Mar '10
by Ingo Siebert (JIRA) 08 Mar '10
08 Mar '10
[ http://jira.qos.ch/browse/LBCLASSIC-57?page=com.atlassian.jira.plugin.syste… ]
Ingo Siebert commented on LBCLASSIC-57:
---------------------------------------
If I understand it right, then this bug had never been fixed.
Why is this closed then?
It also occurs with JDK5.
> SyslogAppender fails sporadically
> ---------------------------------
>
> Key: LBCLASSIC-57
> URL: http://jira.qos.ch/browse/LBCLASSIC-57
> Project: logback-classic
> Issue Type: Bug
> Environment: $ uname -a
> Linux ... 2.6.9-67.ELsmp #1 SMP Wed Nov 7 13:56:44 EST 2007 x86_64 x86_64 x86_64 GNU/Linux
> $ java -version
> java version "1.6.0_03"
> Java(TM) SE Runtime Environment (build 1.6.0_03-b05)
> Java HotSpot(TM) Server VM (build 1.6.0_03-b05, mixed mode)
> multiprocessor PC box
> Reporter: Anton Tagunov
> Assignee: Logback dev list
> Fix For: 0.9.12
>
>
> * several JVM-s per Linux box
> * 5 SyslogAppender-s logging to syslog-ng on 127.0.0.1
> Once in a while one of the SyslogAppender-s (the busiest one with longest messages) stops logging completely
> Other SyslogAppender-ss continue working fine.
> /usr/sbin/tcpdump has confirmed upd packets reach
> syslog-ng port via 'lo' network interface for remaining appends
> /usr/sbin/tcpdump has confirmed NO udp packets reach
> syslog-ng port via 'lo' network interface for the failing appender
> We have JMX enabled. JConsole does show StatusManager messages.
> There are no error messages there.
> Just the messages emitted during initial logback configuration
> from logback.xml on the classpath.
> We had invoked 'reload()' method via JMX.
> StatusMananger messages observed via JMX show that reload had happened.
> Full re-configuration had happened.
> All 5 SyslogAppenders had been apparently re-created.
> Yet NO udp messages had come from the SyslogAppender
> replacing those which had previously failed.
> Reloading did not help at all.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.qos.ch/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
1
0

[GIT] Logback: the generic, reliable, fast and flexible logging framework. branch, master, updated. v0.9.18-68-g9a9462c
by git-noreplyï¼ pixie.qos.ch 05 Mar '10
by git-noreplyï¼ pixie.qos.ch 05 Mar '10
05 Mar '10
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Logback: the generic, reliable, fast and flexible logging framework.".
The branch, master has been updated
via 9a9462cf0af145a7c80fc655ff8298416393b3bd (commit)
from a9729dc84972f7c16fd4b857d9c2b6372d9f4158 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.qos.ch/gitweb/?p=logback.git;a=commit;h=9a9462cf0af145a7c80fc655…
http://github.com/ceki/logback/commit/9a9462cf0af145a7c80fc655ff8298416393b…
commit 9a9462cf0af145a7c80fc655ff8298416393b3bd
Author: Ceki Gulcu <ceki(a)qos.ch>
Date: Sat Mar 6 00:16:39 2010 +0100
editing the manual
diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/action/Action.java b/logback-core/src/main/java/ch/qos/logback/core/joran/action/Action.java
index abbe4f6..ae25ca0 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/joran/action/Action.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/joran/action/Action.java
@@ -50,10 +50,16 @@ public abstract class Action extends ContextAwareBase {
* Called when the parser encounters an element matching a
* {@link ch.qos.logback.core.joran.spi.Pattern Pattern}.
*/
- public abstract void begin(InterpretationContext ec, String name,
+ public abstract void begin(InterpretationContext ic, String name,
Attributes attributes) throws ActionException;
- public void body(InterpretationContext ec, String body)
+ /**
+ * Called to pass the body (as text) contained within an element.
+ * @param ic
+ * @param body
+ * @throws ActionException
+ */
+ public void body(InterpretationContext ic, String body)
throws ActionException {
// NOP
}
@@ -62,34 +68,34 @@ public abstract class Action extends ContextAwareBase {
* Called when the parser encounters an endElement event matching a
* {@link ch.qos.logback.core.joran.spi.Pattern Pattern}.
*/
- public abstract void end(InterpretationContext ec, String name)
+ public abstract void end(InterpretationContext ic, String name)
throws ActionException;
public String toString() {
return this.getClass().getName();
}
- protected int getColumnNumber(InterpretationContext ec) {
- Interpreter jp = ec.getJoranInterpreter();
- Locator locator = jp.getLocator();
+ protected int getColumnNumber(InterpretationContext ic) {
+ Interpreter ji = ic.getJoranInterpreter();
+ Locator locator = ji.getLocator();
if (locator != null) {
return locator.getColumnNumber();
}
return -1;
}
- protected int getLineNumber(InterpretationContext ec) {
- Interpreter jp = ec.getJoranInterpreter();
- Locator locator = jp.getLocator();
+ protected int getLineNumber(InterpretationContext ic) {
+ Interpreter ji = ic.getJoranInterpreter();
+ Locator locator = ji.getLocator();
if (locator != null) {
return locator.getLineNumber();
}
return -1;
}
- protected String getLineColStr(InterpretationContext ec) {
- String line = "line: " + getLineNumber(ec) + ", column: "
- + getColumnNumber(ec);
+ protected String getLineColStr(InterpretationContext ic) {
+ String line = "line: " + getLineNumber(ic) + ", column: "
+ + getColumnNumber(ic);
return line;
}
}
diff --git a/logback-site/src/site/pages/manual/encoders.html b/logback-site/src/site/pages/manual/encoders.html
new file mode 100644
index 0000000..9b2ccad
--- /dev/null
+++ b/logback-site/src/site/pages/manual/encoders.html
@@ -0,0 +1,29 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
+ <title>Chapter 4: Appenders</title>
+ <link rel="stylesheet" type="text/css" href="../css/common.css" />
+ <link rel="stylesheet" type="text/css" href="../css/screen.css" media="screen" />
+ <link rel="stylesheet" type="text/css" href="../css/_print.css" media="print" />
+ <link rel="stylesheet" type="text/css" href="../css/prettify.css" media="screen" /
+ </head>
+ <body onload="prettyPrint()">
+ <script type="text/javascript">prefix='../';</script>
+ <script type="text/javascript" src="../js/prettify.js"></script>
+ <script src="../templates/header.js" type="text/javascript"></script>
+ <div id="left">
+ <noscript>Please turn on Javascript to view this menu</noscript>
+ <script src="../templates/left.js" type="text/javascript"></script>
+ </div>
+ <div id="right">
+ <script src="menu.js" type="text/javascript"></script>
+ </div>
+
+ <div id="content">
+
+ <h1>Chapter 6: Encoders</h1>
+ </div>
+ </body>
+</html>
diff --git a/logback-site/src/site/pages/manual/filters.html b/logback-site/src/site/pages/manual/filters.html
index 716c3f2..4ca854c 100644
--- a/logback-site/src/site/pages/manual/filters.html
+++ b/logback-site/src/site/pages/manual/filters.html
@@ -24,7 +24,7 @@
</div>
<div id="content">
- <h1>Chapter 6: Filters</h1>
+ <h1>Chapter 7: Filters</h1>
<div class="quote">
<p><em>Have lots of ideas and throw away the bad ones. You aren't
diff --git a/logback-site/src/site/pages/manual/index.html b/logback-site/src/site/pages/manual/index.html
index f4ac339..e8d7e21 100644
--- a/logback-site/src/site/pages/manual/index.html
+++ b/logback-site/src/site/pages/manual/index.html
@@ -48,6 +48,7 @@
<li><p>logback configuration scripts in XML format</p></li>
<li><p>appenders</p></li>
<li><p>layouts</p></li>
+ <li><p>encoders</p></li>
<li><p>filters</p></li>
<li><p>mapped diagnostic contexts</p></li>
<li><p>joran, logback's configuration system</p></li>
@@ -89,28 +90,32 @@
<a href="layouts.html"><b>Chapter 5: Layouts</b></a>
</p></li>
+ <li><p>
+ <a href="encoders.html"><b>Chapter 6: Encoders</b></a>
+ </p></li>
+
<li><p>
- <a href="filters.html"><b>Chapter 6: Filters</b></a>
+ <a href="filters.html"><b>Chapter 7: Filters</b></a>
</p></li>
<li><p>
- <a href="mdc.html"><b>Chapter 7: Mapped Diagnostic Context</b></a>
+ <a href="mdc.html"><b>Chapter 8: Mapped Diagnostic Contexts</b></a>
</p></li>
<li><p>
- <a href="loggingSeparation.html"><b>Chapter 8: Logging Separation</b></a>
+ <a href="loggingSeparation.html"><b>Chapter 9: Logging Separation</b></a>
</p></li>
<li><p>
- <a href="jmxConfig.html"><b>Chapter 9: JMX Configurator</b></a>
+ <a href="jmxConfig.html"><b>Chapter 10: JMX Configurator</b></a>
</p></li>
<li><p>
- <a href="onJoran.html"><b>Chapter 10: Joran</b></a>
+ <a href="onJoran.html"><b>Chapter 11: Joran</b></a>
</p></li>
<li><p>
- <a href="migrationFromLog4j.html"><b>Chapter 11: Migration from log4j</b></a>
+ <a href="migrationFromLog4j.html"><b>Chapter 12: Migration from log4j</b></a>
</p></li>
</ul>
diff --git a/logback-site/src/site/pages/manual/jmxConfig.html b/logback-site/src/site/pages/manual/jmxConfig.html
index 96eeb39..5481188 100644
--- a/logback-site/src/site/pages/manual/jmxConfig.html
+++ b/logback-site/src/site/pages/manual/jmxConfig.html
@@ -25,7 +25,7 @@
</div>
<div id="content">
- <h2>JMX Configurator</h2>
+ <h2>Chapter 10: JMX Configurator</h2>
<p>As its name indicates, <code>JMXConfigurator</code> allows
configuration of logback via JMX. In a nutshell, it lets you
diff --git a/logback-site/src/site/pages/manual/loggingSeparation.html b/logback-site/src/site/pages/manual/loggingSeparation.html
index 4350841..ecea848 100644
--- a/logback-site/src/site/pages/manual/loggingSeparation.html
+++ b/logback-site/src/site/pages/manual/loggingSeparation.html
@@ -23,7 +23,7 @@
</div>
<div id="content">
- <h2>Chapter 9: Context Selectors</h2>
+ <h2>Chapter 9: Logging separation</h2>
<div class="quote">
<p><em>It is not knowledge, but the act of learning, not
diff --git a/logback-site/src/site/pages/manual/mdc.html b/logback-site/src/site/pages/manual/mdc.html
index 6529648..8b0bf37 100644
--- a/logback-site/src/site/pages/manual/mdc.html
+++ b/logback-site/src/site/pages/manual/mdc.html
@@ -23,7 +23,7 @@
</div>
<div id="content">
- <h1>Chapter 7: Mapped Diagnostic Context</h1>
+ <h1>Chapter 8: Mapped Diagnostic Context</h1>
<div class="quote">
<p><em>Lock the doors.</em></p>
diff --git a/logback-site/src/site/pages/manual/menu.js b/logback-site/src/site/pages/manual/menu.js
index 5459e11..c41b284 100644
--- a/logback-site/src/site/pages/manual/menu.js
+++ b/logback-site/src/site/pages/manual/menu.js
@@ -5,9 +5,10 @@ document.write('<p class="menu"><a href="architecture.html"><b>Ch2: Architecture
document.write('<p class="menu"><a href="configuration.html"><b>Ch3: Configuration</b></a>');
document.write('<p class="menu"><a href="appenders.html"><b>Ch4: Appenders</b></a>');
document.write('<p class="menu"><a href="layouts.html"><b>Ch5: Layouts</b></a>');
-document.write('<p class="menu"><a href="filters.html"><b>Ch6: Filters</b></a>');
-document.write('<p class="menu"><a href="mdc.html"><b>Ch7: Mapped Diagnostic Contexts</b></a>');
-document.write('<p class="menu"><a href="loggingSeparation.html"><b>Ch8: Logging Separation</b></a>');
-document.write('<p class="menu"><a href="jmxConfig.html"><b>Ch9: JMX Configurator</b></a>');
-document.write('<p class="menu"><a href="onJoran.html"><b>Ch10: Joran</b></a>');
-document.write('<p class="menu"><a href="migrationFromLog4j.html"><b>Ch11: Migration from log4j</b></a>');
+document.write('<p class="menu"><a href="encoders.html"><b>Ch6: Encoders</b></a>');
+document.write('<p class="menu"><a href="filters.html"><b>Ch7: Filters</b></a>');
+document.write('<p class="menu"><a href="mdc.html"><b>Ch8: Mapped Diagnostic Contexts</b></a>');
+document.write('<p class="menu"><a href="loggingSeparation.html"><b>Ch9: Logging Separation</b></a>');
+document.write('<p class="menu"><a href="jmxConfig.html"><b>Ch10: JMX Configurator</b></a>');
+document.write('<p class="menu"><a href="onJoran.html"><b>Ch11: Joran</b></a>');
+document.write('<p class="menu"><a href="migrationFromLog4j.html"><b>Ch12: Migration from log4j</b></a>');
diff --git a/logback-site/src/site/pages/manual/migrationFromLog4j.html b/logback-site/src/site/pages/manual/migrationFromLog4j.html
index b9b6e41..dd392cf 100644
--- a/logback-site/src/site/pages/manual/migrationFromLog4j.html
+++ b/logback-site/src/site/pages/manual/migrationFromLog4j.html
@@ -23,7 +23,7 @@
</div>
<div id="content">
- <h2>Migration from log4j</h2>
+ <h2>Chapter 12: Migration from log4j</h2>
<div class="quote">
<p><em>The more things change, the more they remain the
diff --git a/logback-site/src/site/pages/manual/onJoran.html b/logback-site/src/site/pages/manual/onJoran.html
index b44a270..9c6f259 100644
--- a/logback-site/src/site/pages/manual/onJoran.html
+++ b/logback-site/src/site/pages/manual/onJoran.html
@@ -23,7 +23,7 @@
</div>
<div id="content">
- <h2>Joran in your own applications</h2>
+ <h2>Chapter 11: Joran</h2>
<div class="quote">
<p><em>The answer, my friend, is blowin' in the wind, The answer
@@ -176,24 +176,33 @@ import org.xml.sax.Attributes;
import ch.qos.logback.core.joran.spi.ExecutionContext;
public abstract class Action {
-
-
/**
* Called when the parser encounters an element matching a
* {@link ch.qos.logback.core.joran.spi.Pattern Pattern}.
*/
- public abstract void begin(InterpretationContext ec, String name,
+ public abstract void begin(InterpretationContext ic, String name,
Attributes attributes) throws ActionException;
+ /**
+ * Called to pass the body (as text) contained within an element.
+ */
+ public void body(InterpretationContext ic, String body)
+ throws ActionException {
+ // NOP
+ }
+
/*
* Called when the parser encounters an endElement event matching a
* {@link ch.qos.logback.core.joran.spi.Pattern Pattern}.
*/
- public abstract void end(InterpretationContext ec, String name)
+ public abstract void end(InterpretationContext ic, String name)
throws ActionException;
}</pre>
- <p>Thus, every action must implement the begin and end methods.</p>
+ <p>Thus, every action must implement the <code>begin()</code> and
+ <code>end()</code> methods. The implemetnation of the
+ <code>body()</code> method being optional on account of the
+ empty/nop implementation provided by <code>Action</code>.</p>
<h3><a name="ruleStore" href="#ruleStore">RuleStore</a> </h3>
-----------------------------------------------------------------------
Summary of changes:
.../ch/qos/logback/core/joran/action/Action.java | 30 ++++++++++++--------
logback-site/src/site/pages/manual/encoders.html | 29 +++++++++++++++++++
logback-site/src/site/pages/manual/filters.html | 2 +-
logback-site/src/site/pages/manual/index.html | 17 +++++++----
logback-site/src/site/pages/manual/jmxConfig.html | 2 +-
.../src/site/pages/manual/loggingSeparation.html | 2 +-
logback-site/src/site/pages/manual/mdc.html | 2 +-
logback-site/src/site/pages/manual/menu.js | 13 ++++----
.../src/site/pages/manual/migrationFromLog4j.html | 2 +-
logback-site/src/site/pages/manual/onJoran.html | 21 ++++++++++----
10 files changed, 85 insertions(+), 35 deletions(-)
create mode 100644 logback-site/src/site/pages/manual/encoders.html
hooks/post-receive
--
Logback: the generic, reliable, fast and flexible logging framework.
1
0

[GIT] Logback: the generic, reliable, fast and flexible logging framework. branch, master, updated. v0.9.18-67-ga9729dc
by git-noreplyï¼ pixie.qos.ch 05 Mar '10
by git-noreplyï¼ pixie.qos.ch 05 Mar '10
05 Mar '10
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Logback: the generic, reliable, fast and flexible logging framework.".
The branch, master has been updated
via a9729dc84972f7c16fd4b857d9c2b6372d9f4158 (commit)
from 1a1fc55afe69a0a74c31c765c9ae7fd97273936e (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.qos.ch/gitweb/?p=logback.git;a=commit;h=a9729dc84972f7c16fd4b857…
http://github.com/ceki/logback/commit/a9729dc84972f7c16fd4b857d9c2b6372d9f4…
commit a9729dc84972f7c16fd4b857d9c2b6372d9f4158
Author: Ceki Gulcu <ceki(a)qos.ch>
Date: Fri Mar 5 22:46:58 2010 +0100
edits to the chapter on appenders
diff --git a/logback-examples/src/main/java/chapters/appenders/conf/logback-RollingSizeBased.xml b/logback-examples/src/main/java/chapters/appenders/conf/logback-RollingSizeBased.xml
index 8563e24..43dc771 100644
--- a/logback-examples/src/main/java/chapters/appenders/conf/logback-RollingSizeBased.xml
+++ b/logback-examples/src/main/java/chapters/appenders/conf/logback-RollingSizeBased.xml
@@ -3,20 +3,20 @@
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>test.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
- <fileNamePattern>tests.%i.log.zip</fileNamePattern>
+ <fileNamePattern>test.%i.log.zip</fileNamePattern>
<minIndex>1</minIndex>
<maxIndex>3</maxIndex>
</rollingPolicy>
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
- <maxFileSize>1KB</maxFileSize>
+ <maxFileSize>5MB</maxFileSize>
</triggeringPolicy>
<encoder>
<pattern>%-4relative [%thread] %-5level %logger{35} - %msg%n</pattern>
</encoder>
</appender>
- <root level="debug">
+ <root level="DEBUG">
<appender-ref ref="FILE" />
</root>
</configuration>
diff --git a/logback-examples/src/main/java/chapters/appenders/conf/logbback-sizeAndTime.xml b/logback-examples/src/main/java/chapters/appenders/conf/logbback-sizeAndTime.xml
index de69021..505cd9c 100644
--- a/logback-examples/src/main/java/chapters/appenders/conf/logbback-sizeAndTime.xml
+++ b/logback-examples/src/main/java/chapters/appenders/conf/logbback-sizeAndTime.xml
@@ -1,13 +1,13 @@
<configuration>
<appender name="ROLLING" class="ch.qos.logback.core.rolling.RollingFileAppender">
- <file>${randomOutputDir}z${testId}</file>
+ <file>mylog.txt</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
- <fileNamePattern>
- ${randomOutputDir}${testId}-%d{yyyy-MM-dd_HH_mm_ss}.%i
- </fileNamePattern>
+ <!-- rollover daily -->
+ <fileNamePattern>mylog-%d{yyyy-MM-dd}.%i.txt</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
- <maxFileSize>${sizeThreshold}</maxFileSize>
+ <!-- or whenever the file size reaches 100MB -->
+ <maxFileSize>100MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<encoder>
diff --git a/logback-site/src/site/pages/manual/appenders.html b/logback-site/src/site/pages/manual/appenders.html
index 8e6d07c..1b1c8ef 100644
--- a/logback-site/src/site/pages/manual/appenders.html
+++ b/logback-site/src/site/pages/manual/appenders.html
@@ -39,7 +39,8 @@
<script src="../templates/creative.js" type="text/javascript"></script>
<script src="../templates/setup.js" type="text/javascript"></script>
- <h2>What is an Appender?</h2>
+ <h2><a name="whatIsAnAppender" href="#whatIsAnAppender">What is an
+ Appender?</a></h2>
<p>Logback delegates the task of writing a logging event to
components called appenders. Appenders must implement the <a
@@ -95,7 +96,7 @@ public interface Appender<E> extends LifeCycle, ContextAware, FilterAttachabl
</p>
- <h2><a name="AppenderBase">AppenderBase</a></h2>
+ <h2><a name="AppenderBase" href="#AppenderBase">AppenderBase</a></h2>
<p>The <a href="../xref/ch/qos/logback/core/AppenderBase.html">
<code>ch.qos.logback.core.AppenderBase</code></a> class is an
@@ -220,7 +221,7 @@ public interface Appender<E> extends LifeCycle, ContextAware, FilterAttachabl
dynamically using JavaBeans introspection through setter and getter
methods. </p>
- <h2>Logback-core</h2>
+ <h1>Logback-core</h1>
<p>Logback-core lays the foundation upon which the other logback
modules are built. In general, the components in logback-core
@@ -231,9 +232,9 @@ public interface Appender<E> extends LifeCycle, ContextAware, FilterAttachabl
- <h3>
+ <h2>
<a name="OutputStreamAppender" href="#OutputStreamAppender">OutputStreamAppender</a>
- </h3>
+ </h2>
<p><a
href="../xref/ch/qos/logback/core/OutputStreamAppender.html"><code>OutputStreamAppender</code></a>
@@ -289,10 +290,10 @@ public interface Appender<E> extends LifeCycle, ContextAware, FilterAttachabl
<img src="images/chapters/appenders/appenderClassDiagram.jpg" alt="A UML diagram showing OutputStreamAppender and sub-classes"/>
- <h3>
+ <h2>
<a name="ConsoleAppender"
href="#ConsoleAppender">ConsoleAppender</a>
- </h3>
+ </h2>
<p>The <a href="../xref/ch/qos/logback/core/ConsoleAppender.html">
<code>ConsoleAppender</code></a>, as the name indicates, appends on
@@ -344,7 +345,7 @@ public interface Appender<E> extends LifeCycle, ContextAware, FilterAttachabl
</encoder>
</appender></b>
- <root level="debug">
+ <root level="DEBUG">
<appender-ref ref="STDOUT" />
</root>
</configuration></pre>
@@ -359,9 +360,9 @@ public interface Appender<E> extends LifeCycle, ContextAware, FilterAttachabl
href="../xref/chapters/appenders/ConfigurationTester.html">chapters.appenders.ConfigurationTester</a> src/main/java/chapters/appenders/conf/logback-Console.xml</p>
- <h3>
+ <h2>
<a name="FileAppender" href="#FileAppender">FileAppender</a>
- </h3>
+ </h2>
<p>The <a
href="../xref/ch/qos/logback/core/FileAppender.html"><code>FileAppender</code></a>,
@@ -482,7 +483,7 @@ public interface Appender<E> extends LifeCycle, ContextAware, FilterAttachabl
</encoder>
</appender></b>
- <root level="debug">
+ <root level="DEBUG">
<appender-ref ref="FILE" />
</root>
</configuration></pre>
@@ -547,9 +548,9 @@ public interface Appender<E> extends LifeCycle, ContextAware, FilterAttachabl
<p class="command">java chapters.appenders.ConfigurationTester src/main/java/chapters/appenders/conf/logback-timestamp.xml</p>
- <h3>
+ <h2>
<a name="RollingFileAppender" href="#RollingFileAppender">RollingFileAppender</a>
- </h3>
+ </h2>
<p><a
href="../xref/ch/qos/logback/core/rolling/RollingFileAppender.html"><code>RollingFileAppender</code></a>
@@ -559,16 +560,18 @@ public interface Appender<E> extends LifeCycle, ContextAware, FilterAttachabl
met, change its logging target to another file.
</p>
- <p>There are two important logback components that interact with
- <code>RollingFileAppender</code>. First, a
- <code>RollingPolicy</code> instance attached to the
- <code>RollingFileAppender</code> is responsible for undertaking the
- action for performing a rollover. Second, a
- <code>TriggeringPolicy</code> instance attached to a
- <code>RollingFileAppender</code> will determine if and exactly when
- rollover occurs. Thus, <code>RollingPolicy</code> is responsible
- for the <em>what</em> and <code>TriggeringPolicy</code> is
- responsible for the <em>when</em>.
+ <p>There are two important sub-components that interact with
+ <code>RollingFileAppender</code>. The first
+ <code>RollingFileAppender</code> sub-component, namely
+ <code>RollingPolicy</code>, (<a href="#onRollingPolicies">see
+ below</a>) is responsible for undertaking the actions required for
+ a rollover. A second sub-component of
+ <code>RollingFileAppender</code>, namely
+ <code>TriggeringPolicy</code>, (<a href="#TriggeringPolicy">see
+ below</a>) will determine if and exactly when rollover
+ occurs. Thus, <code>RollingPolicy</code> is responsible for the
+ <em>what</em> and <code>TriggeringPolicy</code> is responsible for
+ the <em>when</em>. <code>RollingPolicy</code> is described
</p>
<p>To be of any use, a <code>RollingFileAppender</code> must have
@@ -659,7 +662,8 @@ public interface Appender<E> extends LifeCycle, ContextAware, FilterAttachabl
</tr>
</table>
- <h3>Rolling policies</h3>
+ <h3><a name="onRollingPolicies" href="#onRollingPolicies">Overview
+ of rolling policies</a></h3>
<p><a
href="../xref/ch/qos/logback/core/rolling/RollingPolicy.html"><code>RollingPolicy</code></a>
@@ -841,7 +845,7 @@ public interface RollingPolicy extends LifeCycle {
<code>FixedWindowRollingPolicy</code>. Note that the <span
class="option">File</span> option is mandatory even if it contains
some of the same information as conveyed with the <span
- class="option">FileNamePattern</span> option.
+ class="option">fileNamePattern</span> option.
</p>
<em>Example 4.<span class="autoEx"/>: Sample configuration of a <code>RollingFileAppender</code> using a
@@ -879,11 +883,16 @@ public interface RollingPolicy extends LifeCycle {
<code>TimeBasedRollingPolicy</code></a> is possibly the most
popular rolling policy. It defines a rollover policy based on time,
for example by day or by month.
+ <code>TimeBasedRollingPolicy</code> assumes the responsibility for
+ rollover as well as for the triggering of said rollover. Indeed,
+ <code>TimeBasedTriggeringPolicy</code> implements both
+ <code>RollingPolicy</code> and <code>TriggeringPolicy</code>
+ interfaces.
</p>
<p><code>TimeBasedRollingPolicy</code>'s admits two properties, the
mandatory <span class="option">fileNamePattern</span> property and
- the optional <span class="option">MaxHistory</span> property.
+ the optional <span class="option">maxHistory</span> property.
</p>
<table class="bodyTable">
@@ -896,12 +905,13 @@ public interface RollingPolicy extends LifeCycle {
<td><b><span class="option">fileNamePattern</span></b></td>
<td><code>String</code></td>
<td>
- <span class="option">FileNamePattern</span> property defines
- the name of the rolled (archived) log files. Its value should
- consist of the name of the file, plus a suitably placed
- <em>%d</em> conversion specifier. The <em>%d</em> conversion
- specifier may contain a date-and-time pattern as specified by
- the <code>java.text.SimpleDateFormat</code> class. If the
+ The mandatory <span class="option">fileNamePattern</span>
+ property defines the name of the rolled (archived) log
+ files. Its value should consist of the name of the file, plus
+ a suitably placed <em>%d</em> conversion specifier. The
+ <em>%d</em> conversion specifier may contain a date-and-time
+ pattern as specified by the
+ <code>java.text.SimpleDateFormat</code> class. If the
date-and-time pattern is omitted, then the default pattern
<em>yyyy-MM-dd</em> is assumed. The <span
class="option">File</span> property in
@@ -925,19 +935,19 @@ public interface RollingPolicy extends LifeCycle {
<p>The date-and-time pattern, as found within the accolades
of %d{} follow java.text.SimpleDateFormat conventions. The
forward slash '/' or backward slash '\' characters anywhere
- within the FileNamePattern property or within the
+ within the fileNamePattern property or within the
date-and-time pattern will be interpreted as directory
separators.
</p>
</td>
</tr>
- <tr>
- <td><span class="option">maxHistory</span></td>
+ <tr class="a">
+ <td><span class="option"><b>maxHistory</b></span></td>
<td>int</td>
- <td>The <span class="option">maxHistory</span> property
- controls the maximum number of archive files to keep,
+ <td>The optional <span class="option">maxHistory</span>
+ property controls the maximum number of archive files to keep,
deleting older files. For example, if you specify monthly
- rollover, and set MaxHistory to 6, then 6 months worth of
+ rollover, and set maxHistory to 6, then 6 months worth of
archives files will be kept with files older than 6 months
deleted. Note as old archived log files are removed, any
folders which were created for the purpose of log file
@@ -1060,12 +1070,13 @@ public interface RollingPolicy extends LifeCycle {
<p>Just like <code>FixedWindowRollingPolicy</code>,
<code>TimeBasedRollingPolicy</code> supports automatic file
compression. This feature is enabled if the value of the <span
- class="option">FileNamePattern</span> option ends with <em>.gz</em>
+ class="option">fileNamePattern</span> option ends with <em>.gz</em>
or <em>.zip</em>.
</p>
+
<table class="bodyTable">
<tr class="a">
- <th><span class="option">FileNamePattern</span></th>
+ <th><span class="option">fileNamePattern</span></th>
<th>Rollover schedule</th>
<th>Example</th>
</tr>
@@ -1107,13 +1118,6 @@ public interface RollingPolicy extends LifeCycle {
resulting archive files will carry different names.
</p>
- <p><code>TimeBasedRollingPolicy</code> assumes the responsibility
- for rollover as well as for the triggering of said
- rollover. Indeed, <code>TimeBasedTriggeringPolicy</code> implements
- both <code>RollingPolicy</code> and <code>TriggeringPolicy</code>
- interfaces.
- </p>
-
<p>By setting the <span class="option">file</span> property you can
decouple the location of the active log file and the location of
the archived log files. The logging output will be targeted into
@@ -1128,7 +1132,7 @@ public interface RollingPolicy extends LifeCycle {
<p>The <span class="option">maxHistory</span> property controls the
maximum number of archive files to keep, deleting older files. For
example, if you specify monthly rollover, and set <span
- class="option">MaxHistory</span> to 6, then 6 months worth of
+ class="option">maxHistory</span> to 6, then 6 months worth of
archives files will be kept with files older than 6 months
deleted. Note as old archived log files are removed, any folders
which were created for the purpose of log file archiving will be
@@ -1155,7 +1159,8 @@ public interface RollingPolicy extends LifeCycle {
<code>TimeBasedRollingPolicy</code>.
</p>
- <em>Example 4.<span class="autoEx"/>: Sample configuration of a <code>RollingFileAppender</code> using a
+ <em>Example 4.<span class="autoEx"/>: Sample configuration of a
+ <code>RollingFileAppender</code> using a
<code>TimeBasedRollingPolicy</code>
(logback-examples/src/main/java/chapters/appenders/conf/logback-RollingTimeBased.xml)</em>
@@ -1168,7 +1173,7 @@ public interface RollingPolicy extends LifeCycle {
<fileNamePattern>logFile.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- keep 30 days' worth of history -->
- <MaxHistory>30</MaxHistory>
+ <maxHistory>30</maxHistory>
</rollingPolicy></b>
<encoder>
@@ -1206,7 +1211,7 @@ public interface RollingPolicy extends LifeCycle {
</encocer>
</appender>
- <root level="debug">
+ <root level="DEBUG">
<appender-ref ref="FILE" />
</root>
</configuration></pre>
@@ -1217,7 +1222,7 @@ public interface RollingPolicy extends LifeCycle {
href="#SizeAndTimeBasedFNATP">Size <b>and</b> time based archiving</a>
</h3>
- <p>You may sometimes wish to archive files essentially by date but
+ <p>Sometimes you may wish to archive files essentially by date but
at the same time limit the size of each log file, in particular if
post-processing tools impose size limits on the log files. In
order to address this requirement, logback ships with a
@@ -1225,53 +1230,54 @@ public interface RollingPolicy extends LifeCycle {
<code>SizeAndTimeBasedFNATP</code>, where FNATP stands for File
Naming And Triggering Policy.</p>
-
+ <p>Here is a sample configuration file demonstrating time and size
+ based log file archiving.</p>
<em>Example 4.<span class="autoEx"/>: Sample configuration for
<code>SizeAndTimeBasedFNATP</code>
(logback-examples/src/main/java/chapters/appenders/conf/logback-sizeAndTime.xml)</em>
<pre class="prettyprint source"><configuration>
- <appender name="ROLLING"
- class="ch.qos.logback.core.rolling.RollingFileAppender">
- <File>mylog.txt</File>
- <rollingPolicy
- class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
- <FileNamePattern>
- <b>mylog-%d{yyyy-MM-dd_HH_mm_ss}.<span class="big red">%i</span>.txt</b>
- </FileNamePattern>
- <b><TimeBasedFileNamingAndTriggeringPolicy</b>
+ <appender name="ROLLING" class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <file>mylog.txt</file>
+ <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+ <!-- rollover daily -->
+ <fileNamePattern><b>mylog-%d{yyyy-MM-dd}.<span class="big red">%i</span>.txt</b></fileNamePattern>
+ <b><timeBasedFileNamingAndTriggeringPolicy</b>
<b>class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"></b>
- <b><MaxFileSize>${sizeThreshold}</MaxFileSize></b>
- <b></TimeBasedFileNamingAndTriggeringPolicy></b>
+ <!-- or whenever the file size reaches 100MB -->
+ <b><maxFileSize>100MB</maxFileSize></b>
+ <b></timeBasedFileNamingAndTriggeringPolicy></b>
</rollingPolicy>
- <layout>
- <Pattern>%msg%n</Pattern>
- </layout>
+ <encoder>
+ <pattern>%msg%n</pattern>
+ </encoder>
</appender>
- <root level="debug">
+ <root level="DEBUG">
<appender-ref ref="ROLLING" />
</root>
</configuration></pre>
- <p>Note the "%i" conversion token in addition to "%d{}". Each time
- the current log file reaches <code>MaxFileSize</code> before the
- current time period end, it will be archived with an increasing
- index, starting at 0.</p>
-
- <p>Size and time based archiving supports cleaning of old archive
- files. You just need to specify the number of periods to preserve
- with the <code><MaxHistory></code> element. When your
+ <p>Note the "%i" conversion token in addition to "%d". Each time
+ the current log file reaches <span
+ class="option">maxFileSize</span> before the current time period
+ ends, it will be archived with an increasing index, starting at
+ 0.</p>
+
+ <p>Size and time based archiving supports deletion of old archive
+ files. You need to specify the number of periods to preserve with
+ the <span class="option">maxHistory</span> property. When your
application is stopped and restarted, logging will continue at the
correct location, i.e. at the largest index number for the current
period.
</p>
- <h3>
- <a name="TriggeringPolicy" href="#TriggeringPolicy">Triggering policy interface</a>
- </h3>
+ <h2>
+ <a name="TriggeringPolicy" href="#TriggeringPolicy">Overview of
+ triggering policies</a>
+ </h2>
<p><a
href="../xref/ch/qos/logback/core/rolling/TriggeringPolicy.html"><code>TriggeringPolicy</code></a>
@@ -1297,6 +1303,11 @@ public interface TriggeringPolicy<E> extends LifeCycle {
rollover should occur or not, based on the said parameters.
</p>
+ <p>The most widely-used triggering policy, namely
+ <code>TimeBasedRollingPolicy</code> which also doubles as a
+ rolliging policy, was already <a
+ href="#TimeBasedRollingPolicy">discussed earlier</a> along with
+ other rolling policies. </p>
<h4><a name="SizeBasedTriggeringPolicy"
href="#SizeBasedTriggeringPolicy">SizeBasedTriggeringPolicy</a></h4>
@@ -1305,49 +1316,49 @@ public interface TriggeringPolicy<E> extends LifeCycle {
href="../xref/ch/qos/logback/core/rolling/SizeBasedTriggeringPolicy.html">
<code>SizeBasedTriggeringPolicy</code></a> looks at size of the
currently active file. If it grows larger than the specified size,
- the <code>FileAppender</code> using the
- <code>SizeBasedTriggeringPolicy</code> will proceed to the
- rollover of the existing active file and create a new one.
+ it will signal the owning <code>RollingFileAppender</code> to
+ trigger the rollover of the existing active file.
</p>
- <p>This <code>TriggeringPolicy</code> accepts only one parameter,
- namely <span class="option">MaxFileSize</span>, with a default
- value of 10 MB.
+ <p><code>SizeBasedTriggeringPolicy</code> accepts only one
+ parameter, namely <span class="option">maxFileSize</span>, with a
+ default value of 10 MB.
</p>
- <p>The <span class="option">MaxFileSize</span> option can be
+ <p>The <span class="option">maxFileSize</span> option can be
specified in bytes, kilobytes, megabytes or gigabytes by suffixing
a numeric value with <em>KB</em>, <em>MB</em> and respectively
<em>GB</em>. For example, <em>5000000</em>, <em>5000KB</em>,
<em>5MB</em> and <em>2GB</em> are all valid values, with the first
- three being also equivalent.
+ three being equivalent.
</p>
<p>Here is a sample configuration with a
<code>RollingFileAppender</code> in conjunction with
- <code>SizeBasedTriggeringPolicy</code>.
+ <code>SizeBasedTriggeringPolicy</code> triggering roll over when
+ the log file reaches 5MB in size.
</p>
<em>Example 4.<span class="autoEx"/>: Sample configuration of a <code>RollingFileAppender</code> using a
<code>SizeBasedTriggeringPolicy</code> (logback-examples/src/main/java/chapters/appenders/conf/logback-RollingSizeBased.xml)</em>
<pre class="prettyprint source"><configuration>
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
- <File>testFile.log</File>
+ <file>test.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
- <FileNamePattern>testFile.%i.log.zip</FileNamePattern>
- <MinIndex>1</MinIndex>
- <MaxIndex>3</MaxIndex>
+ <fileNamePattern>test.%i.log.zip</fileNamePattern>
+ <minIndex>1</minIndex>
+ <maxIndex>3</maxIndex>
</rollingPolicy>
<b><triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
- <MaxFileSize>5MB</MaxFileSize>
+ <maxFileSize>5MB</maxFileSize>
</triggeringPolicy></b>
- <layout class="ch.qos.logback.classic.PatternLayout">
- <Pattern>%-4relative [%thread] %-5level %logger{35} - %msg%n</Pattern>
- </layout>
+ <encoder
+ <pattern>%-4relative [%thread] %-5level %logger{35} - %msg%n</pattern>
+ </encoder>
</appender>
- <root level="debug">
+ <root level="DEBUG">
<appender-ref ref="FILE" />
</root>
</configuration></pre>
@@ -1557,7 +1568,7 @@ public interface TriggeringPolicy<E> extends LifeCycle {
<IncludeCallerData>${includeCallerData}</IncludeCallerData>
</appender>
- <root level="debug">
+ <root level="DEBUG">
<appender-ref ref="SOCKET" />
</root>
@@ -2021,7 +2032,7 @@ Context ctx = new InitialContext(env);</pre>
<TopicBindingName>MyTopic</TopicBindingName>
</appender>
- <root level="debug">
+ <root level="DEBUG">
<appender-ref ref="Topic" />
</root>
</configuration></pre>
@@ -2089,7 +2100,7 @@ Context ctx = new InitialContext(env);</pre>
<QueueBindingName>MyQueue</QueueBindingName>
</appender>
- <root level="debug">
+ <root level="DEBUG">
<appender-ref ref="Queue" />
</root>
</configuration></pre>
@@ -2302,7 +2313,7 @@ Context ctx = new InitialContext(env);</pre>
</layout>
</appender>
- <root level="debug">
+ <root level="DEBUG">
<appender-ref ref="EMAIL" />
</root>
</configuration></pre>
@@ -2468,7 +2479,7 @@ public class CounterBasedEvaluator extends ContextAwareBase implements EventEval
<layout class="ch.qos.logback.classic.html.HTMLLayout"/>
</appender>
- <root level="debug">
+ <root level="DEBUG">
<appender-ref ref="EMAIL" />
</root>
</configuration></pre>
@@ -2571,7 +2582,7 @@ logger.error(<b>notifyAdminMarker</b>,
</layout>
</appender>
- <root level="debug">
+ <root level="DEBUG">
<appender-ref ref="EMAIL" />
</root>
</configuration></pre>
@@ -2602,7 +2613,7 @@ logger.error(<b>notifyAdminMarker</b>,
</layout>
</appender>
- <root level="debug">
+ <root level="DEBUG">
<appender-ref ref="EMAIL" />
</root>
</configuration></pre>
@@ -2914,7 +2925,7 @@ logger.error(<b>notifyAdminMarker</b>,
</connectionSource>
</appender></b>
- <root level="debug" >
+ <root level="DEBUG" >
<appender-ref ref="DB" />
</root>
</configuration></pre>
@@ -3001,7 +3012,7 @@ logger.error(<b>notifyAdminMarker</b>,
</connectionSource>
</appender>
- <root level="debug">
+ <root level="DEBUG">
<appender-ref ref="DB" />
</root>
</configuration></pre>
@@ -3108,7 +3119,7 @@ logger.error(<b>notifyAdminMarker</b>,
</connectionSource>
</appender>
- <root level="debug">
+ <root level="DEBUG">
<appender-ref ref="DB" />
</root>
</configuration</pre>
@@ -3142,7 +3153,7 @@ logger.error(<b>notifyAdminMarker</b>,
</connectionSource>
</appender>
- <root level="debug">
+ <root level="DEBUG">
<appender-ref ref="DB" />
</root>
</configuration></pre>
@@ -3271,7 +3282,7 @@ logger.error(<b>notifyAdminMarker</b>,
<SuffixPattern>[%thread] %logger %msg</SuffixPattern>
</appender>
- <root level="debug">
+ <root level="DEBUG">
<appender-ref ref="STDOUT" />
</root>
</configuration></pre>
-----------------------------------------------------------------------
Summary of changes:
.../appenders/conf/logback-RollingSizeBased.xml | 6 +-
.../appenders/conf/logbback-sizeAndTime.xml | 10 +-
logback-site/src/site/pages/manual/appenders.html | 229 ++++++++++----------
3 files changed, 128 insertions(+), 117 deletions(-)
hooks/post-receive
--
Logback: the generic, reliable, fast and flexible logging framework.
1
0

[GIT] Logback: the generic, reliable, fast and flexible logging framework. branch, master, updated. v0.9.18-66-g1a1fc55
by git-noreplyï¼ pixie.qos.ch 05 Mar '10
by git-noreplyï¼ pixie.qos.ch 05 Mar '10
05 Mar '10
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Logback: the generic, reliable, fast and flexible logging framework.".
The branch, master has been updated
via 1a1fc55afe69a0a74c31c765c9ae7fd97273936e (commit)
from 108c2384db2295b33f7b336818954c20765482f9 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.qos.ch/gitweb/?p=logback.git;a=commit;h=1a1fc55afe69a0a74c31c765…
http://github.com/ceki/logback/commit/1a1fc55afe69a0a74c31c765c9ae7fd972739…
commit 1a1fc55afe69a0a74c31c765c9ae7fd97273936e
Author: Ceki Gulcu <ceki(a)qos.ch>
Date: Fri Mar 5 16:33:16 2010 +0100
Editing the chapter on appenders
diff --git a/logback-examples/src/main/java/chapters/appenders/ConfigurationTester.java b/logback-examples/src/main/java/chapters/appenders/ConfigurationTester.java
index d215a04..5bc4f0a 100644
--- a/logback-examples/src/main/java/chapters/appenders/ConfigurationTester.java
+++ b/logback-examples/src/main/java/chapters/appenders/ConfigurationTester.java
@@ -35,7 +35,6 @@ public class ConfigurationTester {
Logger logger = (Logger) LoggerFactory.getLogger(ConfigurationTester.class);
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
- System.out.println("***********"+args[0]);
try {
JoranConfigurator configurator = new JoranConfigurator();
configurator.setContext(lc);
diff --git a/logback-examples/src/main/java/chapters/appenders/ExitWoes1.java b/logback-examples/src/main/java/chapters/appenders/ExitWoes1.java
deleted file mode 100644
index 29f5bb2..0000000
--- a/logback-examples/src/main/java/chapters/appenders/ExitWoes1.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/**
- * Logback: the reliable, generic, fast and flexible logging framework.
- * Copyright (C) 1999-2009, QOS.ch. All rights reserved.
- *
- * This program and the accompanying materials are dual-licensed under
- * either the terms of the Eclipse Public License v1.0 as published by
- * the Eclipse Foundation
- *
- * or (per the licensee's choosing)
- *
- * under the terms of the GNU Lesser General Public License version 2.1
- * as published by the Free Software Foundation.
- */
-package chapters.appenders;
-
-import java.io.FileOutputStream;
-import java.io.OutputStream;
-
-import org.slf4j.LoggerFactory;
-
-import ch.qos.logback.classic.Logger;
-import ch.qos.logback.classic.LoggerContext;
-import ch.qos.logback.classic.spi.ILoggingEvent;
-import ch.qos.logback.core.OutputStreamAppender;
-import ch.qos.logback.core.encoder.EchoEncoder;
-
-public class ExitWoes1 {
-
- public static void main(String[] args) throws Exception {
- LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
- lc.reset(); // we want to override the default-config.
- OutputStreamAppender<ILoggingEvent> writerAppender = new OutputStreamAppender<ILoggingEvent>();
- writerAppender.setContext(lc);
- writerAppender.setEncoder(new EchoEncoder<ILoggingEvent>());
-
- OutputStream os = new FileOutputStream("exitWoes1.log");
- writerAppender.setOutputStream(os);
- writerAppender.start();
- Logger root = lc.getLogger(Logger.ROOT_LOGGER_NAME);
- root.addAppender(writerAppender);
-
- Logger logger = lc.getLogger(ExitWoes1.class);
-
- logger.debug("Hello world.");
- }
-}
\ No newline at end of file
diff --git a/logback-examples/src/main/java/chapters/appenders/ExitWoes2.java b/logback-examples/src/main/java/chapters/appenders/ExitWoes2.java
deleted file mode 100644
index 6459cc8..0000000
--- a/logback-examples/src/main/java/chapters/appenders/ExitWoes2.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * Logback: the reliable, generic, fast and flexible logging framework.
- * Copyright (C) 1999-2009, QOS.ch. All rights reserved.
- *
- * This program and the accompanying materials are dual-licensed under
- * either the terms of the Eclipse Public License v1.0 as published by
- * the Eclipse Foundation
- *
- * or (per the licensee's choosing)
- *
- * under the terms of the GNU Lesser General Public License version 2.1
- * as published by the Free Software Foundation.
- */
-package chapters.appenders;
-
-import java.io.FileOutputStream;
-import java.io.OutputStream;
-
-import org.slf4j.LoggerFactory;
-
-import ch.qos.logback.classic.Logger;
-import ch.qos.logback.classic.LoggerContext;
-import ch.qos.logback.classic.spi.ILoggingEvent;
-import ch.qos.logback.core.OutputStreamAppender;
-import ch.qos.logback.core.encoder.EchoEncoder;
-import ch.qos.logback.core.util.StatusPrinter;
-
-public class ExitWoes2 {
-
- public static void main(String[] args) throws Exception {
- LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
- lc.reset();//this is to cancel default-config.
- OutputStreamAppender<ILoggingEvent> writerAppender = new OutputStreamAppender<ILoggingEvent>();
- writerAppender.setContext(lc);
- writerAppender.setEncoder(new EchoEncoder<ILoggingEvent>());
-
- OutputStream os = new FileOutputStream("exitWoes2.log");
- writerAppender.setOutputStream(os);
- writerAppender.start();
- Logger root = lc.getLogger(Logger.ROOT_LOGGER_NAME);
- root.addAppender(writerAppender);
-
- Logger logger = lc.getLogger(ExitWoes2.class);
-
- logger.debug("Hello world.");
-
- lc.stop();
-
- StatusPrinter.print(lc);
- }
-}
\ No newline at end of file
diff --git a/logback-examples/src/main/java/chapters/appenders/conf/logback-Console.xml b/logback-examples/src/main/java/chapters/appenders/conf/logback-Console.xml
index 68a72ee..dff6351 100644
--- a/logback-examples/src/main/java/chapters/appenders/conf/logback-Console.xml
+++ b/logback-examples/src/main/java/chapters/appenders/conf/logback-Console.xml
@@ -1,4 +1,4 @@
-<configuration debug="true">
+<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<!-- encoders are assigned the type
@@ -8,7 +8,7 @@
</encoder>
</appender>
- <root level="debug">
+ <root level="DEBUG">
<appender-ref ref="STDOUT" />
</root>
</configuration>
diff --git a/logback-examples/src/main/java/chapters/appenders/conf/logback-PrudentTimeBasedRolling.xml b/logback-examples/src/main/java/chapters/appenders/conf/logback-PrudentTimeBasedRolling.xml
index 54a68b9..9358ff8 100644
--- a/logback-examples/src/main/java/chapters/appenders/conf/logback-PrudentTimeBasedRolling.xml
+++ b/logback-examples/src/main/java/chapters/appenders/conf/logback-PrudentTimeBasedRolling.xml
@@ -13,7 +13,7 @@
</encoder>
</appender>
- <root level="debug">
+ <root level="DEBUG">
<appender-ref ref="FILE" />
</root>
</configuration>
\ No newline at end of file
diff --git a/logback-examples/src/main/java/chapters/appenders/conf/logback-RollingFixedWindow.xml b/logback-examples/src/main/java/chapters/appenders/conf/logback-RollingFixedWindow.xml
index 2315964..1dbd61a 100644
--- a/logback-examples/src/main/java/chapters/appenders/conf/logback-RollingFixedWindow.xml
+++ b/logback-examples/src/main/java/chapters/appenders/conf/logback-RollingFixedWindow.xml
@@ -16,7 +16,7 @@
</encoder>
</appender>
- <root level="debug">
+ <root level="DEBUG">
<appender-ref ref="FILE" />
</root>
</configuration>
\ No newline at end of file
diff --git a/logback-examples/src/main/java/chapters/appenders/conf/logback-RollingTimeBased.xml b/logback-examples/src/main/java/chapters/appenders/conf/logback-RollingTimeBased.xml
index f2db600..ab682df 100644
--- a/logback-examples/src/main/java/chapters/appenders/conf/logback-RollingTimeBased.xml
+++ b/logback-examples/src/main/java/chapters/appenders/conf/logback-RollingTimeBased.xml
@@ -3,7 +3,9 @@
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>logFile.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
- <FileNamePattern>logFile.%d{yyyy-MM-dd}.log</FileNamePattern>
+ <!-- daily rollover -->
+ <fileNamePattern>logFile.%d{yyyy-MM-dd}.log</fileNamePattern>
+
<!-- keep 30 days worth of history -->
<maxHistory>30</maxHistory>
</rollingPolicy>
@@ -13,7 +15,7 @@
</encoder>
</appender>
- <root level="debug">
+ <root level="DEBUG">
<appender-ref ref="FILE" />
</root>
</configuration>
\ No newline at end of file
diff --git a/logback-examples/src/main/java/chapters/appenders/conf/logback-fileAppender.xml b/logback-examples/src/main/java/chapters/appenders/conf/logback-fileAppender.xml
index c67ccda..aba1950 100644
--- a/logback-examples/src/main/java/chapters/appenders/conf/logback-fileAppender.xml
+++ b/logback-examples/src/main/java/chapters/appenders/conf/logback-fileAppender.xml
@@ -11,7 +11,7 @@
</encoder>
</appender>
- <root level="debug">
+ <root level="DEBUG">
<appender-ref ref="FILE" />
</root>
</configuration>
\ No newline at end of file
diff --git a/logback-examples/src/main/java/chapters/appenders/conf/logback-timestamp.xml b/logback-examples/src/main/java/chapters/appenders/conf/logback-timestamp.xml
index 340280b..83d0ab8 100644
--- a/logback-examples/src/main/java/chapters/appenders/conf/logback-timestamp.xml
+++ b/logback-examples/src/main/java/chapters/appenders/conf/logback-timestamp.xml
@@ -14,7 +14,7 @@
</encoder>
</appender>
- <root level="debug">
+ <root level="DEBUG">
<appender-ref ref="FILE" />
</root>
</configuration>
diff --git a/logback-site/src/site/pages/manual/appenders.html b/logback-site/src/site/pages/manual/appenders.html
index 2469859..8e6d07c 100644
--- a/logback-site/src/site/pages/manual/appenders.html
+++ b/logback-site/src/site/pages/manual/appenders.html
@@ -257,17 +257,28 @@ public interface Appender<E> extends LifeCycle, ContextAware, FilterAttachabl
</tr>
<tr class="a">
- <td><b><span class="option">Encoder</span></b></td>
- <td><code>Encoder</code></td>
+ <td><b><span class="option">encoder</span></b></td>
+ <td><a
+ href="../xref/ch/qos/logback/core/encoder/Encoder.html"><code>Encoder</code></a></td>
<td>Determines the manner in which an event is written to the
underlying <code>OutputStreamAppender</code>. Encoders are
- described in a <a href="encoders.html">dictated chapter</a>.
+ described in a <a href="encoders.html">dedicated chapter</a>.
</td>
</tr>
</table>
+ <p>Given the structure of current hard drives and performance tests
+ we have conducted, it appears that turning off immediate flushing or
+ buffering of character to byte conversions have rather small impact
+ on performance. As such, as of logback vesion 0.9.19, the <span
+ class="option">ImmediateFlush</span>, <span
+ class="option">BufferedIO</span> and <span
+ class="option">BufferSize</span> properties have been removed
+ without replacement.
+ </p>
+
<p>The <code>OutputStreamAppender</code> is the superclass of three other
appenders, namely <code>ConsoleAppender</code>,
<code>FileAppender</code> which in turn is the super class of
@@ -287,12 +298,12 @@ public interface Appender<E> extends LifeCycle, ContextAware, FilterAttachabl
<code>ConsoleAppender</code></a>, as the name indicates, appends on
the console, or more precisely on <em>System.out</em> or
<em>System.err</em>, the former being the default
- target. <code>ConsoleAppender</code> formats events with a layout
- specified by the user. Layouts will be discussed in the next
- chapter. Both <em>System.out</em> and <em>System.err</em> are
- <code>java.io.PrintStream</code> objects. Consequently, they are
- wrapped inside an <code>OutputStreamWriter</code> which buffers I/O
- operations but not character conversions.
+ target. <code>ConsoleAppender</code> formats events with the hellp
+ of an encoder specified by the user. Encoders will be discussed in a
+ subsequent chapter. Both <em>System.out</em> and <em>System.err</em>
+ are of type <code>java.io.PrintStream</code>. Consequently, they
+ are wrapped inside an <code>OutputStreamWriter</code> which buffers
+ I/O operations.
</p>
<table class="bodyTable">
@@ -302,12 +313,14 @@ public interface Appender<E> extends LifeCycle, ContextAware, FilterAttachabl
<th>Description</th>
</tr>
<tr class="b">
- <td><b><span class="option">Encoder</span></b></td>
- <td><code>Encoder</code></td>
+ <td><b><span class="option">encoder</span></b></td>
+ <td>
+ <a href="../xref/ch/qos/logback/core/encoder/Encoder.html"><code>Encoder</code></a>
+ </td>
<td>See <code>OutputStreamAppender</code> properties.</td>
</tr>
<tr class="a">
- <td><b><span class="option">Target</span></b></td>
+ <td><b><span class="option">target</span></b></td>
<td><code>String</code></td>
<td>
One of the String values <em>System.out</em> or
@@ -324,8 +337,10 @@ public interface Appender<E> extends LifeCycle, ContextAware, FilterAttachabl
<pre class="prettyprint source"><configuration>
<b><appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
- <encoder class="ch.qos.logback.classic.PatternLayout">
- <Pattern>%-4relative [%thread] %-5level %logger{35} - %msg %n</Pattern>
+ <!-- encoders are assigned the type
+ ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
+ <encoder>
+ <pattern>%-4relative [%thread] %-5level %logger{35} - %msg %n</pattern>
</encoder>
</appender></b>
@@ -335,8 +350,9 @@ public interface Appender<E> extends LifeCycle, ContextAware, FilterAttachabl
</configuration></pre>
<p>After you have set your current path to the
- <em>logback-examples</em> directory, you can give the above
- configuration file a whirl by issuing the following command:
+ <em>logback-examples</em> directory and <a href="../setup.html">set
+ up your class path</a>, you can give the above configuration file a
+ whirl by issuing the following command:
</p>
<p class="source">java <a
@@ -353,15 +369,7 @@ public interface Appender<E> extends LifeCycle, ContextAware, FilterAttachabl
a file. The target file is specified by the <span
class="option">File</span> option. If the file already exists, it
is either appended to, or truncated depending on the value of the
- <span class="option">Append</span> option.
- <code>FileAppender</code> uses a <code>FileOutputStream</code>
- which is wrapped by an <code>OutputStreamWriter</code>. Note that
- <code>OutputStreamWriter</code> buffers I/O operations but not
- character conversions. To optimize character conversions one can
- set the <span class="option">BufferedIO</span> option to true which
- effectively wraps the <code>OutputStreamWriter</code> with a
- <code>BufferedWriter</code>. Properties for <code>FileAppender</code>
- are summarized below.
+ <span class="option">Append</span> option.
</p>
<table class="bodyTable properties">
@@ -371,7 +379,7 @@ public interface Appender<E> extends LifeCycle, ContextAware, FilterAttachabl
<th>Description</th>
</tr>
<tr class="alt">
- <td><b><span class="option">Append</span></b></td>
+ <td><b><span class="option">append</span></b></td>
<td><code>boolean</code></td>
<td>If true, events are appended at the end of an existing
file. Otherwise, if <span class="option">Append</span> is
@@ -381,14 +389,16 @@ public interface Appender<E> extends LifeCycle, ContextAware, FilterAttachabl
</td>
</tr>
<tr >
- <td><b><span class="option">Encoding</span></b></td>
- <td><code>String</code></td>
+ <td><b><span class="option">encoder</span></b></td>
+ <td>
+ <a href="../xref/ch/qos/logback/core/encoder/Encoder.html"><code>Encoder</code></a>
+ </td>
<td>See <code>OutputStreamAppender</code> properties.</td>
</tr>
<tr class="alt">
- <td><b><span class="option">File</span></b></td>
+ <td><b><span class="option">file</span></b></td>
<td><code>String</code></td>
<td>The name of the file to write to. If the file does not
exist, it is created. On the MS Windows platform users
@@ -400,9 +410,9 @@ public interface Appender<E> extends LifeCycle, ContextAware, FilterAttachabl
<em>c:\\temp\\test.log</em>. The <span
class="option">File</span> option has no default value.
- <p>If the parent directory of the file does now exist, the
- FileAppender will automatically create it, including any
- necessary but nonexistent parent directories.
+ <p>If the parent directory of the file does not exist,
+ <code>FileAppender</code> will automatically create it,
+ including any necessary but nonexistent parent directories.
</p>
</td>
</tr>
@@ -410,7 +420,7 @@ public interface Appender<E> extends LifeCycle, ContextAware, FilterAttachabl
<tr >
<td><b><span class="option bold"><a name="prudent"
- href="#prudent">Prudent</a></span></b></td>
+ href="#prudent">prudent</a></span></b></td>
<td><code>boolean</code></td>
<td>In prudent mode, <code>FileAppeder</code> will safely
@@ -435,6 +445,17 @@ public interface Appender<E> extends LifeCycle, ContextAware, FilterAttachabl
second in prudent mode.
</p>
+ <p>Prudent mode effectively serializes IO operations between
+ all JVMs writing to the same file. Thus, as he number of JVMs
+ competing to access the file increases so will the delay
+ incurred by each I/O operation. As long as the <em>total</em>
+ number of I/O operations is in the order of 20 log requests
+ per second, the impact on performance should be
+ negligible. Applications generating 100 or more I/O
+ operations per second can see an impact on performance and
+ should avoid using <span class="option">prudent</span> mode.
+ </p>
+
<p>Prudent mode can be used in conjunction with
<code>RollingFileAppender</code> although some <a
href="#prudentWithRolling">restrictions apply</a>.
@@ -452,9 +473,9 @@ public interface Appender<E> extends LifeCycle, ContextAware, FilterAttachabl
<pre class="prettyprint source"><configuration>
<b><appender name="FILE" class="ch.qos.logback.core.FileAppender">
- <File>testFile.log</File>
- <Append>true</Append>
- <!-- encoders are assigned the type
+ <file>testFile.log</file>
+ <append>true</append>
+ <!-- encoders are assigned the type
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
<encoder>
<pattern>%-4relative [%thread] %-5level %logger{35} - %msg%n</pattern>
@@ -497,13 +518,13 @@ public interface Appender<E> extends LifeCycle, ContextAware, FilterAttachabl
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<!-- use the previously created timestamp to create a uniquely
named log file -->
- <File><b>log-${bySecond}.txt</b></File>
- <layout>
- <Pattern>%logger{35} - %msg%n</Pattern>
- </layout>
+ <file><b>log-${bySecond}.txt</b></file>
+ <encoder>
+ <pattern>%logger{35} - %msg%n</pattern>
+ </encoder>
</appender>
- <root level="debug">
+ <root level="DEBUG">
<appender-ref ref="FILE" />
</root>
</configuration></pre>
@@ -522,6 +543,10 @@ public interface Appender<E> extends LifeCycle, ContextAware, FilterAttachabl
href="http://java.sun.com/j2se/1.4.2/docs/api/java/text/SimpleDateFormat.html">SimpleDateFormat</a>.
</p>
+ <p>Experiment with by running the command:</p>
+
+ <p class="command">java chapters.appenders.ConfigurationTester src/main/java/chapters/appenders/conf/logback-timestamp.xml</p>
+
<h3>
<a name="RollingFileAppender" href="#RollingFileAppender">RollingFileAppender</a>
</h3>
@@ -541,7 +566,7 @@ public interface Appender<E> extends LifeCycle, ContextAware, FilterAttachabl
action for performing a rollover. Second, a
<code>TriggeringPolicy</code> instance attached to a
<code>RollingFileAppender</code> will determine if and exactly when
- rollover happens Thus, <code>RollingPolicy</code> is responsible
+ rollover occurs. Thus, <code>RollingPolicy</code> is responsible
for the <em>what</em> and <code>TriggeringPolicy</code> is
responsible for the <em>when</em>.
</p>
@@ -563,45 +588,32 @@ public interface Appender<E> extends LifeCycle, ContextAware, FilterAttachabl
<th>Description</th>
</tr>
<tr class="b">
- <td><b><span class="option">Append</span></b></td>
- <td><code>boolean</code></td>
+ <td><b><span class="option">file</span></b></td>
+ <td><code>String</code></td>
<td>See <code>FileAppender</code> properties.</td>
</tr>
<tr class="a">
- <td><b><span class="option">BufferedIO</span></b></td>
+ <td><b><span class="option">append</span></b></td>
<td><code>boolean</code></td>
<td>See <code>FileAppender</code> properties.</td>
- </tr>
- <tr class="b">
- <td><b><span class="option">BufferSize</span></b></td>
- <td><code>int</code></td>
- <td>See <code>FileAppender</code> properties.</td>
- </tr>
- <tr class="a">
- <td><b><span class="option">Encoding</span></b></td>
- <td><code>String</code></td>
- <td>See <code>OutputStreamAppender</code> properties.</td>
</tr>
<tr class="b">
- <td><b><span class="option">File</span></b></td>
- <td><code>String</code></td>
- <td>See <code>FileAppender</code> properties.</td>
- </tr>
- <tr class="a">
- <td><b><span class="option">ImmediateFlush</span></b></td>
- <td><code>boolean</code></td>
+ <td><b><span class="option">encoder</span></b></td>
+ <td>
+ <a href="../xref/ch/qos/logback/core/encoder/Encoder.html"><code>Encoder</code></a>
+ </td>
<td>See <code>OutputStreamAppender</code> properties.</td>
- </tr>
- <tr class="b">
- <td><b><span class="option">RollingPolicy</span></b></td>
+ </tr>
+ <tr class="a">
+ <td><b><span class="option">rollingPolicy</span></b></td>
<td><code>RollingPolicy</code></td>
<td>This option is the component that will dictate
<code>RollingFileAppender</code>'s behavior when rollover
occurs. See more information below.
</td>
</tr>
- <tr class="a">
- <td><b><span class="option">TriggeringPolicy</span></b></td>
+ <tr class="b">
+ <td><b><span class="option">triggeringPolicy</span></b></td>
<td><code>TriggeringPolicy</code></td>
<td>
This option is the component that will tell
@@ -609,9 +621,9 @@ public interface Appender<E> extends LifeCycle, ContextAware, FilterAttachabl
procedure. See more information below.
</td>
</tr>
- <tr class="b">
+ <tr class="a">
<td valign="top"><span class="option"><a name="prudentWithRolling"
- href="#prudentWithRolling"><b>Prudent</b></a></span></td>
+ href="#prudentWithRolling"><b>prudent</b></a></span></td>
<td valign="top"><code>boolean</code></td>
@@ -634,7 +646,7 @@ public interface Appender<E> extends LifeCycle, ContextAware, FilterAttachabl
allowed. (We can't have one JVM writing to a file while
another JVM is compressing it.) </li>
- <li>The <span class="option">File</span> property of
+ <li>The <span class="option">file</span> property of
<code>FileAppender</code> cannot be set and must be left
blank. Indeed, most operating systems do not allow renaming
of a file while another process has it opened.
@@ -651,8 +663,8 @@ public interface Appender<E> extends LifeCycle, ContextAware, FilterAttachabl
<p><a
href="../xref/ch/qos/logback/core/rolling/RollingPolicy.html"><code>RollingPolicy</code></a>
- is responsible for the rollover procedure. It manages file renaming
- and in occasion file deleting.</p>
+ is responsible for the rollover procedure which involves file
+ moving and renaming.</p>
<p>The <code>RollingPolicy</code> interface is presented below:</p>
@@ -664,17 +676,19 @@ import ch.qos.logback.core.spi.LifeCycle;
public interface RollingPolicy extends LifeCycle {
<b>public void rollover() throws RolloverFailure;</b>
- public String getNewActiveFileName();
+ public String getActiveFileName();
+ public CompressionMode getCompressionMode();
public void setParent(FileAppender appender);
}</pre>
- <p>The <code>rollover</code> method proceeds to the file change,
- renaming or deletion. The <code>getNewActiveFileName()</code>
- method is called to compute a new file name, with respect to the
- configuration elements that were injected into the
- <code>RollingPolicy</code>. Lastly, a <code>RollingPolicy</code>
- is given a reference to its parent via the <code>setParent</code>
- method.
+ <p>The <code>rollover</code> method accomplishes the work involved
+ in archiving the current log file. The
+ <code>getActiveFileName()</code> method is called to compute a the
+ file name of the current log file (where live logs are written
+ to). As indicated by <code>getCompressionMode</code> method a
+ RollingPolicy is also responsible for determining the compression
+ mode. Lastly, a <code>RollingPolicy</code> is given a reference to
+ its parent via the <code>setParent</code> method.
</p>
<h4>
@@ -688,7 +702,7 @@ public interface RollingPolicy extends LifeCycle {
to a fixed window algorithm as described below.
</p>
- <p>The <span class="option">FileNamePattern</span> option
+ <p>The <span class="option">fileNamePattern</span> option
represents the file name pattern for the archived (rolled over) log
files. This option is required and must include an integer token
<em>%i</em> somewhere within the pattern.
@@ -705,7 +719,7 @@ public interface RollingPolicy extends LifeCycle {
<th>Description</th>
</tr>
<tr class="b">
- <td><b><span class="option">MinIndex</span></b></td>
+ <td><b><span class="option">minIndex</span></b></td>
<td><code>int</code></td>
<td>
<p>This option represents the lower bound for the window's
@@ -714,7 +728,7 @@ public interface RollingPolicy extends LifeCycle {
</td>
</tr>
<tr class="a">
- <td><b><span class="option">MaxIndex</span></b></td>
+ <td><b><span class="option">maxIndex</span></b></td>
<td><code>int</code></td>
<td>
<p>This option represents the upper bound for the window's
@@ -723,7 +737,7 @@ public interface RollingPolicy extends LifeCycle {
</td>
</tr>
<tr class="b">
- <td><b><span class="option">FileNamePattern</span></b></td>
+ <td><b><span class="option">fileNamePattern</span></b></td>
<td><code>String</code></td>
<td>
<p>This option represents the pattern that will be followed
@@ -737,12 +751,12 @@ public interface RollingPolicy extends LifeCycle {
will produce archive files named <em>MyLogFile1.log</em>,
<em>MyLogFile2.log</em> and <em>MyLogFile3.log</em>.
</p>
- <p>Note that file compression is also specified via the <span
- class="option">FileNamePattern</span> option. For example, the
- file name pattern <em>MyLogFile%i.log.zip</em> will indicate
- to the <code>FixedWindowRollingPolicy</code> that the archived
- file must be compressed using the <em>zip</em> format;
- <em>gz</em> format is also supported.
+ <p>Note that file compression is also specified via this
+ property. For example, <span
+ class="option">fileNamePattern</span> set to
+ <em>MyLogFile%i.log.zip</em> means that archived file must be
+ compressed using the <em>zip</em> format; <em>gz</em> format
+ is also supported.
</p>
</td>
</tr>
@@ -750,18 +764,17 @@ public interface RollingPolicy extends LifeCycle {
<p>Given that the fixed window rolling policy requires as many file
renaming operations as the window size, large window sizes are
- strongly discouraged. The current implementation will automatically
- reduce the window size to 12, when larger values are specified by
- the user.
+ strongly discouraged. When large values are specified by the user,
+ the current implementation will automatically reduce the window
+ size to 12.
</p>
- <p>Let us go over a more concrete example of the fixed windows
- rollover policy. Suppose that the <span
- class="option">MinIndex</span> is set to <em>1</em>, <span
- class="option">MaxIndex</span> set to <em>3</em>, that <span
- class="option">FileNamePattern</span> option is set to
- <em>foo%i.log</em>, and that <span
- class="option">FileNamePattern</span> option is set to
+ <p>Let us go over a more concrete example of the fixed window
+ rollover policy. Suppose that <span class="option">minIndex</span>
+ is set to <em>1</em>, <span class="option">maxIndex</span> set to
+ <em>3</em>, <span class="option">fileNamePattern</span> property
+ set to <em>foo%i.log</em>, and that <span
+ class="option">fileNamePattern</span> property is set to
<em>foo.log</em>.
</p>
@@ -836,23 +849,23 @@ public interface RollingPolicy extends LifeCycle {
<pre class="prettyprint source"><configuration>
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
- <b><File>test.log</File></b>
+ <b><file>test.log</file></b>
<b><rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
- <FileNamePattern>tests.%i.log.zip</FileNamePattern>
- <MinIndex>1</MinIndex>
- <MaxIndex>3</MaxIndex>
+ <fileNamePattern>tests.%i.log.zip</fileNamePattern>
+ <minIndex>1</minIndex>
+ <maxIndex>3</maxIndex>
</rollingPolicy></b>
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
- <MaxFileSize>5MB</MaxFileSize>
+ <maxFileSize>5MB</maxFileSize>
</triggeringPolicy>
- <layout class="ch.qos.logback.classic.PatternLayout">
- <Pattern>%-4relative [%thread] %-5level %logger{35} - %msg%n</Pattern>
- </layout>
+ <encoder>
+ <pattern>%-4relative [%thread] %-5level %logger{35} - %msg%n</pattern>
+ </encoder>
</appender>
- <root level="debug">
+ <root level="DEBUG">
<appender-ref ref="FILE" />
</root>
</configuration></pre>
@@ -869,40 +882,80 @@ public interface RollingPolicy extends LifeCycle {
</p>
<p><code>TimeBasedRollingPolicy</code>'s admits two properties, the
- mandatory <span class="option">FileNamePattern</span> property and
+ mandatory <span class="option">fileNamePattern</span> property and
the optional <span class="option">MaxHistory</span> property.
</p>
-
- <p><span class="option">FileNamePattern</span> property defines the
- name of the rolled (archived) log files. Its value should consist
- of the name of the file, plus a suitably placed <em>%d</em>
- conversion specifier. The <em>%d</em> conversion specifier may
- contain a date-and-time pattern as specified by the
- <code>java.text.SimpleDateFormat</code> class. If the
- date-and-time pattern is omitted, then the default pattern
- <em>yyyy-MM-dd</em> is assumed. The <span
- class="option">File</span> property in
- <code>RollingFileAppender</code> (the parent of
- <code>TimeBasedRollingPolicy</code>) can be either set or omitted.
- </p>
+ <table class="bodyTable">
+ <tr class="a">
+ <th>Property Name</th>
+ <th>Type</th>
+ <th>Description</th>
+ </tr>
+ <tr class="b">
+ <td><b><span class="option">fileNamePattern</span></b></td>
+ <td><code>String</code></td>
+ <td>
+ <span class="option">FileNamePattern</span> property defines
+ the name of the rolled (archived) log files. Its value should
+ consist of the name of the file, plus a suitably placed
+ <em>%d</em> conversion specifier. The <em>%d</em> conversion
+ specifier may contain a date-and-time pattern as specified by
+ the <code>java.text.SimpleDateFormat</code> class. If the
+ date-and-time pattern is omitted, then the default pattern
+ <em>yyyy-MM-dd</em> is assumed. The <span
+ class="option">File</span> property in
+ <code>RollingFileAppender</code> (the parent of
+ <code>TimeBasedRollingPolicy</code>) can be either set or
+ omitted.
+
+ <p>By setting the <span class="option">file</span> property
+ of the containig <code>FileAppender</code>, you can decouple
+ the location of the active log file and the location of the
+ archived log files. The current logs will be always targeted
+ at the file specified by the <span class="option">file</span>
+ property. It follows that the name of the currently active
+ log file will not change over time. However, if you choose to
+ omit the <span class="option">file</span> property, then the
+ active file will be computed anew for each period based on
+ the value of <span class="option">fileNamePattern</span>.
+ The examples below should clarify the point.
+ </p>
- <p>By setting the <span class="option">File</span> property you can
- decouple the location of the active log file and the location of
- the archived log files. The current logs will be always targeted at
- the file specified by the <span class="option">File</span>
- property. It follows that the name of the currently active log file
- will not change over time. However, if you choose to omit the <span
- class="option">File</span> property, then the active file will be
- computed anew for each period based on the value of <span
- class="option">FileNamePattern</span>. The following examples
- should clarify the point.
- </p>
+ <p>The date-and-time pattern, as found within the accolades
+ of %d{} follow java.text.SimpleDateFormat conventions. The
+ forward slash '/' or backward slash '\' characters anywhere
+ within the FileNamePattern property or within the
+ date-and-time pattern will be interpreted as directory
+ separators.
+ </p>
+ </td>
+ </tr>
+ <tr>
+ <td><span class="option">maxHistory</span></td>
+ <td>int</td>
+ <td>The <span class="option">maxHistory</span> property
+ controls the maximum number of archive files to keep,
+ deleting older files. For example, if you specify monthly
+ rollover, and set MaxHistory to 6, then 6 months worth of
+ archives files will be kept with files older than 6 months
+ deleted. Note as old archived log files are removed, any
+ folders which were created for the purpose of log file
+ archiving will be removed as appropriate.
+ </td>
+ </tr>
+ </table>
+
+
+ <p>Here are a few <code>fileNamePattern</code> values with an
+ explanation of their effects.</p>
+
+
<table class="bodyTable">
<tr class="a">
<th>
- <span class="option">FileNamePattern</span>
+ <span class="option">fileNamePattern</span>
</th>
<th>Rollover schedule</th>
<th>Example</th>
@@ -918,14 +971,14 @@ public interface RollingPolicy extends LifeCycle {
</td>
<td>
- <p><span class="option">File</span> property not set: During November
+ <p><span class="option">file</span> property not set: During November
23rd, 2006, logging output will go to the file
<em>/wombat/foo.2006-11-23</em>. At midnight and for the
rest of the 24th, logging output will be directed to
<em>/wombat/foo.2006-11-24</em>.
</p>
- <p><span class="option">File</span> property set to
+ <p><span class="option">file</span> property set to
<em>/wombat/foo.txt</em>: During November 23rd, 2006, logging
output will go to the file <em>/wombat/foo.txt</em>. At
midnight, <em>foo.txt</em> will be renamed as
@@ -945,14 +998,14 @@ public interface RollingPolicy extends LifeCycle {
</td>
<td>Rollover at the beginning of each month.</td>
<td>
- <p><span class="option">File</span> property not set: During the
- month of October 2006, logging output will go to
+ <p><span class="option">file</span> property not set: During
+ the month of October 2006, logging output will go to
<em>/wombat/2006/10/foo.txt</em>. After midnight of October
31st and for the rest of November, logging output will be
directed to <em>/wombat/2006/11/foo.txt</em>.
</p>
- <p><span class="option">File</span> property set to
+ <p><span class="option">file</span> property set to
<em>/wombat/foo.txt</em>: The active log file will always be
<em>/wombat/foo.txt</em>. During the month of October 2006,
logging output will go to <em>/wombat/foo.txt</em>. At
@@ -1003,165 +1056,154 @@ public interface RollingPolicy extends LifeCycle {
folders.
</p>
- <p>The date-and-time pattern, as found within accolades in %d{}
- follow java.text.SimpleDateFormat conventions. This any characters
- within the date-and-time pattern outside the ranges
- <em>['a'..'z']</em> and <em>['A'..'Z']</em> will be treated as
- quoted text. For instance, characters like <em>'.'</em>, <em>'
- '</em>, <em>'#'</em> and <em>'@'</em> will appear in the resulting
- time text even when they are not enclosed within single
- quotes. Nevertheless, we recommend against using the colon
- <em>':'</em> character anywhere within the <span
- class="option">FileNamePattern</span> option. The text before the
- colon is interpreted as the protocol specification of a URL, which
- is most probably not what you intend. The forward slash
- <em>'/'</em> or backward slash <em>'\'</em> characters anywhere
- within the <span class="option">FileNamePattern</span> property or
- within the date-and-time pattern will be interpreted as directory
- separators and any missing directories will be created as
- necessary.
- </p>
-
- <p>Just like <code>FixedWindowRollingPolicy</code>,
- <code>TimeBasedRollingPolicy</code> supports automatic file
- compression. This feature is enabled if the value of the <span
- class="option">FileNamePattern</span> option ends with <em>.gz</em>
- or <em>.zip</em>.
- </p>
- <table class="bodyTable">
- <tr class="a">
- <th><span class="option">FileNamePattern</span></th>
- <th>Rollover schedule</th>
- <th>Example</th>
- </tr>
- <tr class="b">
- <td><em>/wombat/foo.%d.gz</em></td>
- <td>Daily rollover (at midnight) with automatic GZIP compression of the
- archived files.</td>
- <td>
- <p><span class="option">File</span> property not set: During
- November 23rd, 2009, logging output will go to the file
- <em>/wombat/foo.2009-11-23</em>. However, at midnight that
- file will be compressed to become
- <em>/wombat/foo.2009-11-23.gz</em>. For the 24th of November,
- logging output will be directed to
- <em>/wombat/folder/foo.2009-11-24</em> until it's rolled over
- at the beginning of the next day.
- </p>
-
- <p><span class="option">File</span> property set to
- /wombat/foo.txt: During November 23rd, 2009, logging output
- will go to the file <em>/wombat/foo.txt</em>. At midnight that
- file will be compressed and renamed as
- <em>/wombat/foo.2009-11-23.gz</em>. A new
- <em>/wombat/foo.txt</em> file will be created where logging
- output will go for the rest of November 24rd. At midnight
- November 24th, <em>/wombat/foo.txt</em> will be compressed and
- renamed as <em>/wombat/foo.2009-11-24.gz</em>. and so on.
- </p>
- </td>
- </tr>
- </table>
-
- <p>The <span class="option">FileNamePattern</span> serves a dual
- purpose. First, by studying the pattern, logback computes the
- requested rollover periodicity. Second, it computes each archived
- file's name. Note that it is possible for two different patterns to
- specify the same periodicity. The patterns <em>yyyy-MM</em> and
- <em>yyyy@MM</em> both specify monthly rollover, although the
- resulting archive files will carry different names.
- </p>
+ <p>Just like <code>FixedWindowRollingPolicy</code>,
+ <code>TimeBasedRollingPolicy</code> supports automatic file
+ compression. This feature is enabled if the value of the <span
+ class="option">FileNamePattern</span> option ends with <em>.gz</em>
+ or <em>.zip</em>.
+ </p>
+ <table class="bodyTable">
+ <tr class="a">
+ <th><span class="option">FileNamePattern</span></th>
+ <th>Rollover schedule</th>
+ <th>Example</th>
+ </tr>
+ <tr class="b">
+ <td><em>/wombat/foo.%d.gz</em></td>
+ <td>Daily rollover (at midnight) with automatic GZIP compression of the
+ archived files.</td>
+ <td>
+ <p><span class="option">file</span> property not set: During
+ November 23rd, 2009, logging output will go to the file
+ <em>/wombat/foo.2009-11-23</em>. However, at midnight that
+ file will be compressed to become
+ <em>/wombat/foo.2009-11-23.gz</em>. For the 24th of November,
+ logging output will be directed to
+ <em>/wombat/folder/foo.2009-11-24</em> until it's rolled over
+ at the beginning of the next day.
+ </p>
+
+ <p><span class="option">file</span> property set to
+ /wombat/foo.txt: During November 23rd, 2009, logging output
+ will go to the file <em>/wombat/foo.txt</em>. At midnight that
+ file will be compressed and renamed as
+ <em>/wombat/foo.2009-11-23.gz</em>. A new
+ <em>/wombat/foo.txt</em> file will be created where logging
+ output will go for the rest of November 24rd. At midnight
+ November 24th, <em>/wombat/foo.txt</em> will be compressed and
+ renamed as <em>/wombat/foo.2009-11-24.gz</em>. and so on.
+ </p>
+ </td>
+ </tr>
+ </table>
+
+ <p>The <span class="option">fileNamePattern</span> serves a dual
+ purpose. First, by studying the pattern, logback computes the
+ requested rollover periodicity. Second, it computes each archived
+ file's name. Note that it is possible for two different patterns to
+ specify the same periodicity. The patterns <em>yyyy-MM</em> and
+ <em>yyyy@MM</em> both specify monthly rollover, although the
+ resulting archive files will carry different names.
+ </p>
- <p><code>TimeBasedRollingPolicy</code> assumes the responsibility
- for rollover as well as for the triggering of said rollover. Indeed,
- <code>TimeBasedTriggeringPolicy</code> implements both
- <code>RollingPolicy</code> and <code>TriggeringPolicy</code>
- interfaces.
- </p>
+ <p><code>TimeBasedRollingPolicy</code> assumes the responsibility
+ for rollover as well as for the triggering of said
+ rollover. Indeed, <code>TimeBasedTriggeringPolicy</code> implements
+ both <code>RollingPolicy</code> and <code>TriggeringPolicy</code>
+ interfaces.
+ </p>
- <p>By setting the <span class="option">File</span> property you can
- decouple the location of the active log file and the location of the
- archived log files. The logging output will be targeted into the
- file specified by the <span class="option">File</span> property. It
- follows that the name of the active log file will not change over
- time. However, if you choose to omit the <span
- class="option">File</span> property, then the active file will be
- computed anew for each period based on the value of <span
- class="option">FileNamePattern</span>.
- </p>
+ <p>By setting the <span class="option">file</span> property you can
+ decouple the location of the active log file and the location of
+ the archived log files. The logging output will be targeted into
+ the file specified by the <span class="option">file</span>
+ property. It follows that the name of the active log file will not
+ change over time. However, if you choose to omit the <span
+ class="option">File</span> property, then the active file will be
+ computed anew for each period based on the value of <span
+ class="option">fileNamePattern</span>.
+ </p>
- <p>The <span class="option">MaxHistory</span> property controls the
- maximum number of archive files to keep, deleting older files. For
- example, if you specify monthly rollover, and set <span
- class="option">MaxHistory</span> to 6, then 6 months worth of
- archives files will be kept with files older than 6 months
- deleted. Note as old archived log files are removed, any folders
- which were created for the purpose of log file archiving will be
- removed as appropriate.
- </p>
+ <p>The <span class="option">maxHistory</span> property controls the
+ maximum number of archive files to keep, deleting older files. For
+ example, if you specify monthly rollover, and set <span
+ class="option">MaxHistory</span> to 6, then 6 months worth of
+ archives files will be kept with files older than 6 months
+ deleted. Note as old archived log files are removed, any folders
+ which were created for the purpose of log file archiving will be
+ removed as appropriate.
+ </p>
+ <p>For various technical reasons, rollovers are not clock-driven
+ but depend on the arrival of logging events. For example, on 8th of
+ March 2002, assuming the <span
+ class="option">fileNamePattern</span> is set to <em>yyyy-MM-dd</em>
+ (daily rollover), the arrival of the first event after midnight
+ will trigger a rollover. If there are no logging events during, say
+ 23 minutes and 47 seconds after midnight, then rollover will
+ actually occur at 00:23'47 AM on March 9th and not at 0:00 AM.
+ Thus, depending on the arrival rate of events, rollovers might be
+ triggered with some latency. However, regardless of the delay, the
+ rollover algorithm is known to be correct, in the sense that all
+ logging events generated during a certain period will be output in
+ the correct file delimiting that period.
+ </p>
- <p>For various technical reasons, rollovers are not clock-driven but
- depend on the arrival of logging events. For example, on 8th of
- March 2002, assuming the <span class="option">FileNamePattern</span>
- is set to <em>yyyy-MM-dd</em> (daily rollover), the arrival of the
- first event after midnight will trigger a rollover. If there are no
- logging events during, say 23 minutes and 47 seconds after midnight,
- then rollover will actually occur at 00:23'47 AM on March 9th and
- not at 0:00 AM. Thus, depending on the arrival rate of events,
- rollovers might be triggered with some latency. However, regardless
- of the delay, the rollover algorithm is known to be correct, in the
- sense that all logging events generated during a certain period will
- be output in the correct file delimiting that period.
- </p>
-
- <p>Here is a sample configuration for
- <code>RollingFileAppender</code> in conjunction with a
- <code>TimeBasedRollingPolicy</code>.
- </p>
+ <p>Here is a sample configuration for
+ <code>RollingFileAppender</code> in conjunction with a
+ <code>TimeBasedRollingPolicy</code>.
+ </p>
- <em>Example 4.<span class="autoEx"/>: Sample configuration of a <code>RollingFileAppender</code> using a
- <code>TimeBasedRollingPolicy</code> (logback-examples/src/main/java/chapters/appenders/conf/logback-RollingTimeBased.xml)</em>
- <pre class="prettyprint source"><configuration>
+ <em>Example 4.<span class="autoEx"/>: Sample configuration of a <code>RollingFileAppender</code> using a
+
+ <code>TimeBasedRollingPolicy</code>
+ (logback-examples/src/main/java/chapters/appenders/conf/logback-RollingTimeBased.xml)</em>
+
+ <pre class="prettyprint source"><configuration>
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
- <File>logFile.log</File>
+ <file>logFile.log</file>
<b><rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
- <FileNamePattern>logFile.%d{yyyy-MM-dd}.log</FileNamePattern>
+ <!-- daily rollover -->
+ <fileNamePattern>logFile.%d{yyyy-MM-dd}.log</fileNamePattern>
+
<!-- keep 30 days' worth of history -->
<MaxHistory>30</MaxHistory>
</rollingPolicy></b>
- <layout class="ch.qos.logback.classic.PatternLayout">
- <Pattern>%-4relative [%thread] %-5level %logger{35} - %msg%n</Pattern>
- </layout>
+ <encoder>
+ <pattern>%-4relative [%thread] %-5level %logger{35} - %msg%n</pattern>
+ </encoder>
</appender>
- <root level="debug">
+ <root level="DEBUG">
<appender-ref ref="FILE" />
</root>
</configuration></pre>
<p>The next configuration sample illustrates the use of
<code>RollingFileAppender</code> associated with
- <code>TimeBasedRollingPolicy</code> in <span class="option">Prudent</span>
+ <code>TimeBasedRollingPolicy</code> in <span class="option">prudent</span>
mode.
</p>
- <em>Example 4.<span class="autoEx"/>: Sample configuration of a <code>RollingFileAppender</code> using a
- <code>TimeBasedRollingPolicy</code> (logback-examples/src/main/java/chapters/appenders/conf/logback-PrudentTimeBasedRolling.xml)</em>
+ <em>Example 4.<span class="autoEx"/>: Sample configuration of a
+ <code>RollingFileAppender</code> using a
+ <code>TimeBasedRollingPolicy</code>
+ (logback-examples/src/main/java/chapters/appenders/conf/logback-PrudentTimeBasedRolling.xml)</em>
+
<pre class="prettyprint source"><configuration>
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<b><!-- Support multiple-JVM writing to the same log file --></b>
- <b><Prudent>true</Prudent></b>
+ <b><prudent>true</prudent></b>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
- <FileNamePattern>logFile.%d{yyyy-MM-dd}.log</FileNamePattern>
- <MaxHistory>30</MaxHistory>
+ <fileNamePattern>logFile.%d{yyyy-MM-dd}.log</fileNamePattern>
+ <maxHistory>30</maxHistory>
</rollingPolicy>
- <layout class="ch.qos.logback.classic.PatternLayout">
- <Pattern>%-4relative [%thread] %-5level %logger{35} - %msg%n</Pattern>
- </layout>
+ <encoder>
+ <pattern>%-4relative [%thread] %-5level %logger{35} - %msg%n</pattern>
+ </encocer>
</appender>
<root level="debug">
-----------------------------------------------------------------------
Summary of changes:
.../chapters/appenders/ConfigurationTester.java | 1 -
.../main/java/chapters/appenders/ExitWoes1.java | 46 --
.../main/java/chapters/appenders/ExitWoes2.java | 51 --
.../chapters/appenders/conf/logback-Console.xml | 4 +-
.../conf/logback-PrudentTimeBasedRolling.xml | 2 +-
.../appenders/conf/logback-RollingFixedWindow.xml | 2 +-
.../appenders/conf/logback-RollingTimeBased.xml | 6 +-
.../appenders/conf/logback-fileAppender.xml | 2 +-
.../chapters/appenders/conf/logback-timestamp.xml | 2 +-
logback-site/src/site/pages/manual/appenders.html | 580 +++++++++++---------
10 files changed, 321 insertions(+), 375 deletions(-)
delete mode 100644 logback-examples/src/main/java/chapters/appenders/ExitWoes1.java
delete mode 100644 logback-examples/src/main/java/chapters/appenders/ExitWoes2.java
hooks/post-receive
--
Logback: the generic, reliable, fast and flexible logging framework.
1
0