Hi I came across some code which is using log4j. I want to move to log4j2. From http://logging.apache.org/log4j/2.x/manual/migration.html I came to that log4j-1.2-api.jar can be used. I have following question :
你好,我遇到了一些使用log4j的代码。我想转移到log4j2。从http://logging.apache.org/log4j/2.x/manual/migr.html我找到了log4j-1.2-api。可以使用jar。我有一个问题:
-
In code I have a custom appender (as given in that link I should not use internals of class Appender) is that mean I can't use log4j-1.2-api.jar ?
在代码中,我有一个定制的appender(在这个链接中,我不应该使用类appender的内部构件),这意味着我不能使用log4j-1.2-api。罐子吗?
-
I also want to use asyn logging feature of log4j2 . How do I do that using log4j-1.2-api.jar.
我还想使用log4j2的asyn日志功能。如何使用log4j-1.2-api.jar来实现这一点。
2 个解决方案
#1
3
- Your custom appender may no longer work. Log4j2 has a lot of functionality, and depending on what your custom appender did, it could be that this functionality already exists in log4j2. You can ask on one of the mailing lists and if it is a function that could be useful for many users it may be added to log4j2.
- 您的定制应用程序可能不再工作。Log4j2有很多功能,根据您的自定义appender做了什么,可能这个功能已经存在于Log4j2中。您可以询问邮件列表中的一个,如果它是一个对许多用户有用的函数,那么它可能会被添加到log4j2中。
- To use the async loggers, you can either make all loggers async with a system property (http://logging.apache.org/log4j/2.x/manual/async.html#AllAsync) or mix synchronous and async loggers with configuration (http://logging.apache.org/log4j/2.x/manual/async.html#MixedSync-Async). Both should work when you drop in the log4j-1.2-api jar (in addition to the log4j-api and log4j-core jars, these two jars are always needed).
- 要使用async记录器,您可以使用系统属性使所有logger (http://logging.apache.org/log4j .org/log4j/2.x/manual/async.html#AllAsync)或将同步和async logger与配置混合(http://logging.apache.org/log4j/2.x/manual/async.html#MixedSync-Async)。当您放入log4j-1.2-api jar时,这两个jar都应该可以工作(除了log4j-api和log4j-core jar之外,这两个jar总是需要的)。
#2
2
There is a migration guide. I used it successfully.
有一个迁移指南。我成功地使用它。
http://logging.apache.org/log4j/2.x/manual/migration.html
http://logging.apache.org/log4j/2.x/manual/migration.html
In log4j2
everything is cofigured using a XML file (or more XML files, e. g. for your test directory). The file should be named log4j2.xml
.
在log4j2中,所有内容都使用一个XML文件(或者更多的XML文件,例如您的测试目录)进行协作。该文件应该命名为log4j2.xml。
#1
3
- Your custom appender may no longer work. Log4j2 has a lot of functionality, and depending on what your custom appender did, it could be that this functionality already exists in log4j2. You can ask on one of the mailing lists and if it is a function that could be useful for many users it may be added to log4j2.
- 您的定制应用程序可能不再工作。Log4j2有很多功能,根据您的自定义appender做了什么,可能这个功能已经存在于Log4j2中。您可以询问邮件列表中的一个,如果它是一个对许多用户有用的函数,那么它可能会被添加到log4j2中。
- To use the async loggers, you can either make all loggers async with a system property (http://logging.apache.org/log4j/2.x/manual/async.html#AllAsync) or mix synchronous and async loggers with configuration (http://logging.apache.org/log4j/2.x/manual/async.html#MixedSync-Async). Both should work when you drop in the log4j-1.2-api jar (in addition to the log4j-api and log4j-core jars, these two jars are always needed).
- 要使用async记录器,您可以使用系统属性使所有logger (http://logging.apache.org/log4j .org/log4j/2.x/manual/async.html#AllAsync)或将同步和async logger与配置混合(http://logging.apache.org/log4j/2.x/manual/async.html#MixedSync-Async)。当您放入log4j-1.2-api jar时,这两个jar都应该可以工作(除了log4j-api和log4j-core jar之外,这两个jar总是需要的)。
#2
2
There is a migration guide. I used it successfully.
有一个迁移指南。我成功地使用它。
http://logging.apache.org/log4j/2.x/manual/migration.html
http://logging.apache.org/log4j/2.x/manual/migration.html
In log4j2
everything is cofigured using a XML file (or more XML files, e. g. for your test directory). The file should be named log4j2.xml
.
在log4j2中,所有内容都使用一个XML文件(或者更多的XML文件,例如您的测试目录)进行协作。该文件应该命名为log4j2.xml。