-
Notifications
You must be signed in to change notification settings - Fork 776
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
config file does not allow subcategory to inherit appenders #824
Comments
One of many workarounds: You can call log4js.getLogger('myapp.child').level = 'DEBUG'; |
I'm working in an environment where all of the configuration is done with a config file, so I can't use a API-based workaround. I come from a log4j / log4.net background, with a logger per source file (usually); with that setup, it's nice to be able to configure a hierarchy with inheritance. @nomiddlename , would you consider a PR along these lines?
Is there a use case for allowing a child category's config to completely replace that of the parent? |
Sounds ok to me - having anything unspecified in the child category config inherit from the parent makes sense. |
One caution... With the current implementation, if somebody cranks up the verbosity for a child category, that extra 'noise' won't be sent to the appenders specified for the parent, unless the same appenders are specified for the child. The functionality I'm suggesting would break that, since child appenders would be in addition to those of the parent. Perhaps we should include an option to keep the old behaviour? Say, "inherit": "OFF"? Log4j subcategories also inherit appenders, unless the child category has "additivity=false". IMO, "inherit=off" is more clear. |
This PR has resolved this issue. Unless a category has inherit=false, it will a) merge in unique appenders from parent categories, and b) inherit the level from the parent category if it doesn't specify its own level directly. This inheritance is recursive. |
Contrary to the description of category hierarchies here, it seems that if I define a child category in a config file without appenders, the config file validation fails with the error,
Here's my config:
A quick scan of the code suggests that if we do a getLogger('myapp.child'), and there is no config for myapp.child, we'll inherit all of 'myapp's config, but if there is a config for that child, it needs to be complete.
The text was updated successfully, but these errors were encountered: