logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ralph Goers (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (LOG4J2-133) Allow custom message creation via a message factory
Date Thu, 06 Dec 2012 16:18:09 GMT

    [ https://issues.apache.org/jira/browse/LOG4J2-133?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13511492#comment-13511492

Ralph Goers commented on LOG4J2-133:

I like the concept as it makes sense that user's would want to use a particular style within
the scope of a Logger.  A few comments on the patch (also posted to the mailing list).

First, I expected MessageFactory to be an interface, not a class.

Second, I expected to see 3 MessageFactory implementations to start that would allow the user
to choose between ParameterizedMessage, StringFormatMessage and MessageFormatMessage (I have
that in the works for JUL support).

Third, I expected that only the methods that accept a format and a parameter would use the
MessageFactory and SimpleMessage and ObjectMessage would just be left as they are. That doesn't
mean I couldn't be persuaded to include them in the interface as I could see uses customizing
that for their needs.

Lastly, I'm not sure how adding getThrowable to the Message interface is related or required
for this change.  I'm not necessarily opposed but I'm not sure if it should be tied to this.
> Allow custom message creation via a message factory
> ---------------------------------------------------
>                 Key: LOG4J2-133
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-133
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: API
>    Affects Versions: 2.0-beta3
>         Environment: Apache Maven 3.0.4 (r1232337; 2012-01-17 03:44:56-0500)
> Maven home: C:\Java\apache-maven-3.0.4\bin\..
> Java version: 1.6.0_35, vendor: Sun Microsystems Inc.
> Java home: C:\Program Files\Java\jdk1.6.0_35\jre
> Default locale: en_US, platform encoding: Cp1252
> OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"
>            Reporter: Gary Gregory
>         Attachments: log4j2-133.diff
> My goal here is to be able to say:
> Logger log = LogManager.getLogger(Foo.class, new MyMessageFactory())
> Where MyMessageFactory extends a MessageFactory:
> and overrides:
>     public Message newMessage(String message, Object... params) {
>         return new ParameterizedMessage(message, params);
>     }
> as:
>     public Message newMessage(String message, Object... params) {
>         return new StringFormattedMessage(message, params);
>     }
> which would let me use native Java formatting instead of {} formatting /easily/
> I've attach the idea as the beginning of patch, which is missing the LogManager bits.
> Maybe we need a sub-interface of Message for param message, which would make me want
to rename the class ParameterizedMessage to SimpleParameterizedMessage.

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org

View raw message