
I've got a logback.xml config (pasted below). All I'm trying to do is have a different logging level, as well as slightly different encoder pattern, for what shows up in the console vs. what gets written to a file. I understand that you have to create 2 different appenders, FILE and CONSOLE, then set root logger for console only with leve="info", and create a separate logger referencing FILE appender with a different logging level. I've done this, but I can't figure out how to set the logger name to a wildcard so I can get "ALL" output directed to the file. You see, just like the root logger that has no "name", I want that for the <logger> as well, but it requires a name and I've tried putting "*" in it and it doesn't work. I don't want to log just "com.acme.*" output, I want to log everything the root logger is logging. Help please! Thank you. <configuration> <appender name="FILE" class="ch.qos.logback.core.FileAppender"> <file>../logs/esign-app.log</file> <encoder> <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %level [%thread] [%class{0}:%line] %msg%n</pattern> </encoder> </appender> <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender"> <encoder> <pattern>%d{HH:mm:ss.SSS} %level [%thread] [%class{0}:%line] %msg%n</pattern> </encoder> </appender> <logger name="com.acme" level="debug" additivity="false"> <appender-ref ref="FILE" /> </logger> <root level="info"> <appender-ref ref="CONSOLE" /> </root> </configuration>

To do this you need the root logger set to level debug and configured with both appenders. You then have to add a ThresholdFilter to the Console appender set to level "info". Ralph On Apr 7, 2011, at 5:13 PM, Joseph Schmoley wrote:
I've got a logback.xml config (pasted below). All I'm trying to do is have a different logging level, as well as slightly different encoder pattern, for what shows up in the console vs. what gets written to a file.
I understand that you have to create 2 different appenders, FILE and CONSOLE, then set root logger for console only with leve="info", and create a separate logger referencing FILE appender with a different logging level.
I've done this, but I can't figure out how to set the logger name to a wildcard so I can get "ALL" output directed to the file. You see, just like the root logger that has no "name", I want that for the <logger> as well, but it requires a name and I've tried putting "*" in it and it doesn't work. I don't want to log just "com.acme.*" output, I want to log everything the root logger is logging.
Help please!
Thank you.
<configuration> <appender name="FILE" class="ch.qos.logback.core.FileAppender"> <file>../logs/esign-app.log</file> <encoder> <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %level [%thread] [%class{0}:%line] %msg%n</pattern> </encoder> </appender>
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender"> <encoder> <pattern>%d{HH:mm:ss.SSS} %level [%thread] [%class{0}:%line] %msg%n</pattern> </encoder> </appender>
<logger name="com.acme" level="debug" additivity="false"> <appender-ref ref="FILE" /> </logger>
<root level="info"> <appender-ref ref="CONSOLE" /> </root> </configuration>
_______________________________________________ Logback-user mailing list Logback-user@qos.ch http://qos.ch/mailman/listinfo/logback-user

Hello Ralph, Hello Joseph, I am under the impression that Joseph is not yet familiar with appender additivity nor logger level inherirance. Both concepts are explained under Chapter 2: Architecture [1]. Joseph, please rectify if my impression is incorrect. [1] http://logback.qos.ch/manual/architecture.html -- Ceki QOS.ch, main sponsor of cal10n, logback and slf4j open source projects, is looking to hire talented software engineers. For further details, see http://logback.qos.ch/job.html On 08.04.2011 09:09, Ralph Goers wrote:
To do this you need the root logger set to level debug and configured with both appenders. You then have to add a ThresholdFilter to the Console appender set to level "info".
Ralph
On Apr 7, 2011, at 5:13 PM, Joseph Schmoley wrote:
I've got a logback.xml config (pasted below). All I'm trying to do is have a different logging level, as well as slightly different encoder pattern, for what shows up in the console vs. what gets written to a file.
I understand that you have to create 2 different appenders, FILE and CONSOLE, then set root logger for console only with leve="info", and create a separate logger referencing FILE appender with a different logging level.
I've done this, but I can't figure out how to set the logger name to a wildcard so I can get "ALL" output directed to the file. You see, just like the root logger that has no "name", I want that for the <logger> as well, but it requires a name and I've tried putting "*" in it and it doesn't work. I don't want to log just "com.acme.*" output, I want to log everything the root logger is logging.
Help please!
Thank you.
<configuration> <appender name="FILE" class="ch.qos.logback.core.FileAppender"> <file>../logs/esign-app.log</file> <encoder> <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %level [%thread] [%class{0}:%line] %msg%n</pattern> </encoder> </appender> <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender"> <encoder> <pattern>%d{HH:mm:ss.SSS} %level [%thread] [%class{0}:%line] %msg%n</pattern> </encoder> </appender> <logger name="com.acme" level="debug" additivity="false"> <appender-ref ref="FILE" /> </logger>
<root level="info"> <appender-ref ref="CONSOLE" /> </root> </configuration>

Hi Ceki, Yes, it appears I didn't have a complete understanding of the concepts. I'd also missed Chapter 7 about the <filter> elements. Thanks to both you and Ralph for the pointers. It's doing exactly what I want now. Also, congrats on a job well done on LogBack. It's a great improvement to Log4j. -Jac On Fri, Apr 8, 2011 at 2:22 AM, Ceki Gulcu <ceki@qos.ch> wrote:
Hello Ralph, Hello Joseph,
I am under the impression that Joseph is not yet familiar with appender additivity nor logger level inherirance. Both concepts are explained under Chapter 2: Architecture [1]. Joseph, please rectify if my impression is incorrect.
[1] http://logback.qos.ch/manual/architecture.html -- Ceki
QOS.ch, main sponsor of cal10n, logback and slf4j open source projects, is looking to hire talented software engineers. For further details, see http://logback.qos.ch/job.html
On 08.04.2011 09:09, Ralph Goers wrote:
To do this you need the root logger set to level debug and configured with both appenders. You then have to add a ThresholdFilter to the Console appender set to level "info".
Ralph
On Apr 7, 2011, at 5:13 PM, Joseph Schmoley wrote:
I've got a logback.xml config (pasted below). All I'm trying to do is
have a different logging level, as well as slightly different encoder pattern, for what shows up in the console vs. what gets written to a file.
I understand that you have to create 2 different appenders, FILE and CONSOLE, then set root logger for console only with leve="info", and create a separate logger referencing FILE appender with a different logging level.
I've done this, but I can't figure out how to set the logger name to a wildcard so I can get "ALL" output directed to the file. You see, just like the root logger that has no "name", I want that for the <logger> as well, but it requires a name and I've tried putting "*" in it and it doesn't work. I don't want to log just "com.acme.*" output, I want to log everything the root logger is logging.
Help please!
Thank you.
<configuration> <appender name="FILE" class="ch.qos.logback.core.FileAppender"> <file>../logs/esign-app.log</file> <encoder> <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %level [%thread] [%class{0}:%line] %msg%n</pattern> </encoder> </appender> <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender"> <encoder> <pattern>%d{HH:mm:ss.SSS} %level [%thread] [%class{0}:%line] %msg%n</pattern> </encoder> </appender> <logger name="com.acme" level="debug" additivity="false"> <appender-ref ref="FILE" /> </logger>
<root level="info"> <appender-ref ref="CONSOLE" /> </root> </configuration>
_______________________________________________ Logback-user mailing list Logback-user@qos.ch http://qos.ch/mailman/listinfo/logback-user
participants (3)
-
Ceki Gulcu
-
Joseph Schmoley
-
Ralph Goers