[
https://issues.apache.org/jira/browse/LOG4J2-476?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13860071#comment-13860071
]
Tal Liron commented on LOG4J2-476:
----------------------------------
Oh, interesting! Actually, the documentation doesn't really explain how this
used, it only mentions how properties defined in the configuration file can be
used in other places in the file. So, in the above example, can the custom
logger property be used in appender layout patterns? In the documentation
example you are pointing to, "user" is not being used in the appender. I
suggest adding a section to the documentation with an explicit example of using
the "user" in an appender pattern, as this is a really great feature.
I would suggest that this "bug" can be fixed by adding the ability to add such
custom properties to *appenders*. The issue of adding the hostname to
distributed logging environments is an appender issue, not a logger issue: in
my centralized log, I want all log messages that pass through to have an origin
IP address.
This is such a common use case that I suggest adding a whole section to the
documentation about distributed logging. You can show how to create
configurations with a SockAppender and have a central SocketServer accepting
all messages and appending them to a file (with the origin IP address).
For my current applications, I had to solve this issue by writing custom
appenders. It's good that this is possible, but I think log4j 2.0 needs an
in-the-box solution for this very common problem.
In case you're curious, here's one of my workarounds:
http://code.google.com/p/sincerity/source/browse/components/sincerity/source/com/threecrickets/sincerity/logging/MongoDbLog4jConnection.java
> 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]