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

Piotr Karwasz commented on LOG4J2-3451:
---------------------------------------

[~Pavel_K],

Yes, the procedure is very similar in 2.x and 3.x:
# you write an appender,
# you annotate it appropriately (the annotations in 2.x and 3.x are different, 
cf. 
[ConsoleAppender|https://github.com/apache/logging-log4j2/blob/master/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/ConsoleAppender.java]
 to see what to use in 3.x),
# you compile your code with the appropriate annotation processor (in 2.x it is 
included in {{log4j-core}}, in 3.x it is included in 
{{log4j-plugin-processor}}),
# in 3.x the processor will create a {{Log4jPlugins.class}} file, you need to 
add a {{provides}} declaration to your module definition (cf. [line 
89|https://github.com/apache/logging-log4j2/blob/da68155a27fc94d7cd20d13f2e4e5c0a9cb9cd67/log4j-core/src/main/java/module-info.java#L89]
 for an example).

This procedure guarantees an automatic detection of your custom components in 
both 2.x and 3.x. The main difference is that 2.x can not find components in 
other modules, while JPMS support is the main feature of 3.x.

As you are certainly aware, 3.x is still work in progress, but snapshots are 
now generated regularly on https://repository.apache.org/snapshots/ and your 
remarks and questions are mostly welcome on the {{log4j-user}} or {{dev}} 
mailing list.

> Custom appenders on module path must be found
> ---------------------------------------------
>
>                 Key: LOG4J2-3451
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-3451
>             Project: Log4j 2
>          Issue Type: Improvement
>    Affects Versions: 2.14.1
>            Reporter: Pavel_K
>            Assignee: Piotr Karwasz
>            Priority: Major
>
> Currently if custom appender is added via config, something like this:
> {code:java}
> <Configuration packages="com.yourcompany.yourcustomappenderpackage">
>   <Appenders>
>     <MyCustomAppender name="ABC" otherAttribute="...">
>     ...
>   </Appenders>
>   <Loggers><Root><AppenderRef ref="ABC" /></Root></Loggers>
> </Configuration>
> {code}
> Log4j2 will find this appender class only if this class is on class path.  I 
> suggest that appenders on module path must also be found.



--
This message was sent by Atlassian Jira
(v8.20.7#820007)

Reply via email to