Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log levels of parent loggers are not applied to messages of children. #17

Closed
naryl opened this issue Aug 23, 2013 · 3 comments
Closed

Comments

@naryl
Copy link
Contributor

naryl commented Aug 23, 2013

I have several packages with different log levels writing to different files and I create a file appender for root logger which should write all ERROR messages from all loggers to error.log. Currently messages are only filtered by the logger they're initiated at so if one package's logger is set to DEBUG root logger would write debug messages to error.log even if it's set to ERROR.

Here's my (log:config)

ROOT, ERROR
|
+-(1)-#<DAILY-FILE-APPENDER {131D9559}>
|     with #<PATTERN-LAYOUT {EC39B39}>
|          :conversion-pattern
|            "%&%<{nopretty}%I%;<;;>;-5p [%D{%H:%M:%S}] %g{}{}{:downcase} (%C{}{ }{:downcase})%2.2N - %:_%m%>%n"
|     :immediate-flush       NIL
|     :flush-interval        1
|     :stream-owner          T
|     :rollover-check-period 60
|     :name-format           #P"/home/naryl/eshop-logs/eshop.log"
|     :backup-name-format    NIL
|     :utc                   NIL
|     :message-count         2962
|
+-ESHOP, DEBUG
| |
| +-(1)-#<THIS-CONSOLE-APPENDER {131E4B31}>
|       with #<PATTERN-LAYOUT {BB97C89}>
|            :conversion-pattern
|              "%&%<{nopretty}%I%;<;;>;-5p [%D{%H:%M:%S}] %g{}{}{:downcase} (%C{}{ }{:downcase})%2.2N - %:_%m%>%n"
|       :immediate-flush NIL
|       :flush-interval  1
|       :stream-owner    NIL
|       :stream          #<SB-SYS:FD-STREAM for "the terminal" {B322409}>
|       :message-count   2962
|
+-SEARCH-TIPS, TRACE
  |
  +-(1)-#<DAILY-FILE-APPENDER {11BC4DE9}>
        with #<PATTERN-LAYOUT {11BC2651}>
             :conversion-pattern
               "%&%<%I%;<;;>;-5p [%D{%H:%M:%S}] %g{}{}{:downcase}%:; ;F (%C{}{ }{:downcase})%2.2N - %:_%m%>%n"
        :immediate-flush       NIL
        :flush-interval        1
        :stream-owner          T
        :rollover-check-period 60
        :name-format           "/home/naryl/eshop-logs/search-tips.log"
        :backup-name-format    NIL
        :utc                   NIL
        :message-count         0
@7max
Copy link
Owner

7max commented Aug 23, 2013

Yes the log messages are filtered against log level once at the point of
entry, and then are propagated to parents.

Perhaps /additivity/ functionality can help you implement what you want?

A logger that is set as non-additive, does not forward messages to parent
loggers at all. (These are intended for big packages that want to have their
own log files).

For example if you set your search-tips and e-shop loggers as non-additive, none of
their messages will appear in appenders attached to the root logger.

You can set them non-additive by adding :own or :noadditive flag to (log:config)
in the same place where you add the rolling file appender.

If that is not flexible enough, then what you want is to have an appender that
filters on log level. Interestingly enough Log4J has this functionality but
since I never used it personally nor known anyone who used it, I thought it
was over-design and did not implement it in log4cl.

Regards,
Max

At Fri, 23 Aug 2013 03:18:15 -0700,
naryl wrote:

I have several packages with different log levels writing to different files and I create a file appender for root logger which
should write all ERROR messages from all loggers to error.log. Currently messages are only filtered by the logger they're
initiated at so if one package's logger is set to DEBUG root logger would write debug messages to error.log even if it's set to
ERROR.

Here's my (log:config)

ROOT, ERROR
|
+-(1)-#<DAILY-FILE-APPENDER {131D9559}>
| with #<PATTERN-LAYOUT {EC39B39}>
| :conversion-pattern
| "%&%<{nopretty}%I%;<;;>;-5p [%D{%H:%M:%S}] %g{}{}{:downcase} (%C{}{ }{:downcase})%2.2N - %:%m%>%n"
| :immediate-flush NIL
| :flush-interval 1
| :stream-owner T
| :rollover-check-period 60
| :name-format #P"/home/naryl/eshop-logs/eshop.log"
| :backup-name-format NIL
| :utc NIL
| :message-count 2962
|
+-ESHOP, DEBUG
| |
| +-(1)-#<THIS-CONSOLE-APPENDER {131E4B31}>
| with #<PATTERN-LAYOUT {BB97C89}>
| :conversion-pattern
| "%&%<{nopretty}%I%;<;;>;-5p [%D{%H:%M:%S}] %g{}{}{:downcase} (%C{}{ }{:downcase})%2.2N - %:
%m%>%n"
| :immediate-flush NIL
| :flush-interval 1
| :stream-owner NIL
| :stream #<SB-SYS:FD-STREAM for "the terminal" {B322409}>
| :message-count 2962
|
+-SEARCH-TIPS, TRACE
|
+-(1)-#<DAILY-FILE-APPENDER {11BC4DE9}>
with #<PATTERN-LAYOUT {11BC2651}>
:conversion-pattern
"%&%<%I%;<;;>;-5p [%D{%H:%M:%S}] %g{}{}{:downcase}%:; ;F (%C{}{ }{:downcase})%2.2N - %:_%m%>%n"
:immediate-flush NIL
:flush-interval 1
:stream-owner T
:rollover-check-period 60
:name-format "/home/naryl/eshop-logs/search-tips.log"
:backup-name-format NIL
:utc NIL
:message-count 0


Reply to this email directly or view it on GitHub.*

@naryl
Copy link
Contributor Author

naryl commented Aug 23, 2013

Ok, mark it invalid. I'll write a level-filtering appender.

@naryl naryl closed this as completed Aug 23, 2013
@7max
Copy link
Owner

7max commented Aug 23, 2013

Cool, it should be a one liner :around method for APPENDER-DO-APPEND for a quick fix.

If you happen to implement a larger patch, with LOG:CONFIG hookup for it, I
would gladly merge it, something like. (LOG:CONFIG ...stuff that adds an
appender... :filter :error). Adding a filter slot to base appender class is
good too, making it NIL by default.

At Fri, 23 Aug 2013 04:28:21 -0700,
naryl wrote:

[1 <text/plain; UTF-8 (7bit)>]

[2 <text/html; UTF-8 (7bit)>]
Ok, mark it invalid. I'll write a level-filtering appender.


Reply to this email directly or view it on GitHub.*

svetlyak40wt pushed a commit to 40ants/log4cl that referenced this issue Dec 2, 2017
check to see if debug-name is an atom before treating it as a list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants