[
https://issues.apache.org/jira/browse/LOG4J2-476?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13860078#comment-13860078
]
Ralph Goers commented on LOG4J2-476:
------------------------------------
The documentation says
{quote}
A LoggerConfig (including the root LoggerConfig) can be configured with
properties that will be added to the properties copied from the
ThreadContextMap. These properties can be referenced from Appenders, Filters,
Layouts, etc just as if they were part of the ThreadContext Map.
{quote}
I'm not sure how to make that clearer.
Adding properties to Appenders can be achieved today by wrapping your Appender
in a RewriteAppender using a PropertiesRewritePolicy. See
http://logging.apache.org/log4j/2.x/manual/appenders.html#RewriteAppender. Note
though that doing it this way could lead to Appenders being configured with
different values.
The enforcement of what you want is actually much easier to do if you have a
bunch of loggers that aren't configured with appenders (but have their own
logging levels) that simply delegate to the root logger where the hostname
property would be specified.
The bottom line is that you shouldn't have to write a custom Appender as there
are multiple ways to get the information into the ThreadContext Map that every
Appender already has access to.
> Add source host to log event for distributed logging
> ----------------------------------------------------
>
> Key: LOG4J2-476
> URL: https://issues.apache.org/jira/browse/LOG4J2-476
> Project: Log4j 2
> Issue Type: Improvement
> Components: Core
> Affects Versions: 2.0-beta9
> Reporter: Tal Liron
> Priority: Critical
>
> It's absolutely necessary to support this: when logging centrally, you *need*
> to know from where the log message arrived. I've marked the issue as
> critical, because log4j is not very useful without it in distributed
> environments. If you don't know where the log message came from, it's close
> to worthless.
> This applies at least to all classes that inherit from
> AbstractDatabaseAppender, but I think the solution should be more generic:
> developers might create their own appenders that would require this
> information. It can be handled, I think, in the same way as
> LogEvent.setIncludeLocation: allow all loggers to include this information if
> configured to do so.
--
This message was sent by Atlassian JIRA
(v6.1.5#6160)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]