How to output all errors to console, and errors+mesgs to logfile?

Hello, I'm a new user and struggling to achieve the following: 1) All "error" messages must go to stdout and a logfile. 2) Based on com.example.myclass level settings, messages also go to logfile. My problem is I can't get both requirement 1 and 2 working simultaneously. The following results in debug messages going to the console. Using additivity="false" results in errors from com.example.myclass not going to the console. Any suggestion is welcome! <configuration> <appender name="ROLLING" class="ch.qos.logback.core.rolling.RollingFileAppender"> ... <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender"> ... <logger name="com.example.myclass" level="debug"> <appender-ref ref="ROLLING"/> </logger> <root level="error"> <appender-ref ref="CONSOLE"/> <appender-ref ref="ROLLING"/> </root> </configuration> Thanks, Robert

Rob skrev:
Hello,
I'm a new user and struggling to achieve the following: 1) All "error" messages must go to stdout and a logfile. 2) Based on com.example.myclass level settings, messages also go to logfile.
My problem is I can't get both requirement 1 and 2 working simultaneously. The following results in debug messages going to the console. Using additivity="false" results in errors from com.example.myclass not going to the console. A possible solution could be:
First make 1 and 2 work for both stdout and logfile without considering that some messages should not go to standard out. Then add a filter for stdout saying you only want messages from a given level and up. -- Thorbjørn Ravn Andersen "...plus... Tubular Bells!"

On 14/02/2010 7:16 PM, Thorbjoern Ravn Andersen wrote:
Rob skrev:
Hello,
I'm a new user and struggling to achieve the following: 1) All "error" messages must go to stdout and a logfile. 2) Based on com.example.myclass level settings, messages also go to logfile.
My problem is I can't get both requirement 1 and 2 working simultaneously. The following results in debug messages going to the console. Using additivity="false" results in errors from com.example.myclass not going to the console. A possible solution could be:
First make 1 and 2 work for both stdout and logfile without considering that some messages should not go to standard out.
Then add a filter for stdout saying you only want messages from a given level and up.
Hello, Requirement 2) is a little vague but I reckon LevelFilter or will ThresholdFilter can help. See http://logback.qos.ch/manual/filters.html#levelFilter and http://logback.qos.ch/manual/filters.html#thresholdFilter HTH,

Ceki Gülcü wrote:
On 14/02/2010 7:16 PM, Thorbjoern Ravn Andersen wrote:
Rob skrev:
Hello,
I'm a new user and struggling to achieve the following: 1) All "error" messages must go to stdout and a logfile. 2) Based on com.example.myclass level settings, messages also go to logfile.
My problem is I can't get both requirement 1 and 2 working simultaneously. The following results in debug messages going to the console. Using additivity="false" results in errors from com.example.myclass not going to the console. A possible solution could be:
First make 1 and 2 work for both stdout and logfile without considering that some messages should not go to standard out.
Then add a filter for stdout saying you only want messages from a given level and up.
Hello,
Requirement 2) is a little vague but I reckon LevelFilter or will ThresholdFilter can help. See
http://logback.qos.ch/manual/filters.html#levelFilter
and
http://logback.qos.ch/manual/filters.html#thresholdFilter
HTH,
My thanks to both of you! I was stuck in a rut thinking I didn't understand logger level inheritance. A thresholdFilter easily fixed my problem. - Robert
participants (3)
-
Ceki Gülcü
-
Rob
-
Thorbjoern Ravn Andersen