Henrik Østerlund Gram | 22 Aug 21:09 2014
Picon

plugin-registration failing

Hi,

I had been using the betas for a couple of years and everything was fine.
 But unfortunately I cannot seem to make 2.0.x work.

I have couple of plugins (converters) that are annotated properly, but the
automatic detection of these never did work and I had to use the follow
maven step to create the necessary Log4j2Plugins.dat for it to work.

<plugin> <groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId> <version>1.2.1</version>
<executions> <execution> <phase>process-classes</phase> <goals>
<goal>java</goal> </goals> </execution> </executions> <configuration>
<mainClass>org.apache.logging.log4j.core.config.plugins.PluginManager</mainClass>
<arguments>
<argument>${project.build.directory}/../src/main/resources</argument>
<argument>my.package</argument> </arguments> </configuration> </plugin>
But since rc2 the PluginManager was disabled, and it's now seemingly
impossible to get the plugins registered. The source for PluginManager
suggests looking at the configuration page supposedly using the packages
attr to tell the framework where to scan for plugins, but again, that just
doesn't work.  I used that as well in the betas where it also did not work.

Perhaps in trivial project setups it works fine, I don't know, but I have
an ear with multiple .wars and a common single log4j2 (present in the ear's
lib where the jar for my converters is also present) and I don't know why
it cannot pick it up.

Any workarounds?  I can't understand why it should be this difficult to
register a converter.
(Continue reading)

Mariano Gonzalez | 22 Aug 19:56 2014
Picon

What's the AsyncLoggerConfig thread?

Hello,

Could you explain what's the purpose of this thread? It seems to keep on
running when my application is undeployed.

I looked at the code and it seems to be a thread responsible for
dispatching events to Disruptor, but if that's the case then the name may
not be very descriptive IMHO. Can you confirm what's the purpose of this
thread and that it should stop after the logging context receives the
stop() message?

Thanks!
Manfred Dohmen | 22 Aug 16:45 2014
Picon

log4j2 and ch.qos.logback.core.PropertyDefinerBase

Hello,

crossposting from here:
http://stackoverflow.com/q/25426738/492462

Logback's PropertyDefinerBase allows to use dynamic properties within 
logback.xml. I use this to configure a target directory for a 
FileAppender with values from my application config. In my case there's 
an enum instance that contains the value I want to use:

public String getPropertyValue() {return MyConfigEnum.LOGDIR.value();}

Relevant parts of logback.xml:

<fileNamePattern>${logdir}/test.log</fileNamePattern>

... and:

<define name="logdir" class="com.example.MyLogdirDefiner" />

This idiom is now needed for log4j 2. How can I apply the value of 
MyConfigEnum.LOGDIR in a log4j2.xml?

I don't want to set a property upon application start.

Regards!
Yogesh Rao | 22 Aug 15:27 2014
Picon

Log4j2 with SL4J Adapter

Hi,

I am trying out the API side of log4j2 with the SLF4J adaptor. With the
sample code written i couldn't see the logging being done properly. Perhaps
i am doing something wrong here.

Firstly versions of the software are :-

1. JDK 1.8.x
2. Log4j2 (2.0.1)
3. SLF4J 1.7.7
4. SLF4J's Simple Logger (1.7.7)

Code written is as under

HelloWorld.java
--------------

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

public class HelloWorld {

private static final Logger logger = LogManager.getLogger("HelloWorld");
    public static void main(String[] args) {
        logger.error("Hello, World!");
        logger.error("Logging in user {} with birthday {}", "Ted",
"1/10/1900");
    }

(Continue reading)

Mikael Ståldal | 20 Aug 11:17 2014

Log4j 2, ThreadContext and asynchronous servlets

Is it possible to have the ThreadContext in Log4j 2 to be request scoped
with asynchronous servlets in a Servlet 3 environment?

With asynchronous servlets, there is no direct connection between request
and thread.

--

-- 
Mikael Ståldal
Chief Software Architect
*Appear*
Phone: +46 8 545 91 572
Email: mikael.staldal <at> appearnetworks.com
Brett Delle Grazie | 19 Aug 13:25 2014
Picon

Log4j2 SyslogAppender / SyslogLayout and message format

Hi,

I'm trying to use the SyslogAppender and possibly the SyslogLayout but I
wanted to customise the message format so that some MDC parameters could be
added to the content of the message (e.g. by applying a pattern layout to
the 'message' portion).

Is there any way of achieving this? There used to be with Log4j 1.2.

I appreciate that this can be done with format 5424 but we're using BSD
format right now.

Thanks,

--

-- 
Kind regards,

Brett
Matt Sicker | 19 Aug 01:53 2014
Picon

Any Apache projects using Log4j2 yet?

I know all the ones I'm interested in haven't added any support yet (other
than the ones that already use SLF4J which gives implicit Log4j2 support).
Have any other projects picked this up yet?

--

-- 
Matt Sicker <boards <at> gmail.com>
Arwen Pond | 8 Aug 20:28 2014

Multiple configuration files?

I have multiple applications that use log4j.  Some depend on others.  For example application A can be run
independently and has a log4j config file under src/main/resources/log4j2.xml.  Application B invokes
application A but it has a different log4j config file in its resource directory.

When there are multiple  log4j2.xml files in the path how are they used/found?  Are they additive?  Does it
just use the first one it finds?

Thanks,
Arwen

This electronic mail message contains information that (a) is or 
may be CONFIDENTIAL, PROPRIETARY IN NATURE, OR OTHERWISE 
PROTECTED 
BY LAW FROM DISCLOSURE, and (b) is intended only for the use of 
the addressee(s) named herein.  If you are not an intended 
recipient, please contact the sender immediately and take the 
steps necessary to delete the message completely from your 
computer system.

Not Intended as a Substitute for a Writing: Notwithstanding the 
Uniform Electronic Transaction Act or any other law of similar 
effect, absent an express statement to the contrary, this e-mail 
message, its contents, and any attachments hereto are not 
intended 
to represent an offer or acceptance to enter into a contract and 
are not otherwise intended to bind this sender, 
barnesandnoble.com 
llc, barnesandnoble.com inc. or any other person or entity.
Mohit Anchlia | 8 Aug 00:16 2014
Picon

Logging using log4j.xml 2

I have below xml but my application is not printing the logs to console. I
am running through eclipse and this file is in main/resources.

<?xml version=*"1.0"* encoding=*"UTF-8"*?>

<Configuration status=*"INFO"* monitorInterval=*"30"*>

<Appenders>

<Console name=*"Console"* target=*"SYSTEM_OUT"*>

<PatternLayout pattern=*"%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} -
%msg%n"*/>

</Console>

</Appenders>

<Loggers>

<Root level=*"INFO"*>

<AppenderRef ref=*"Console"*/>

</Root>

</Loggers>

</Configuration>
(Continue reading)

Arwen Pond | 6 Aug 23:03 2014

Set the file name based on command line args

My application takes a parameter where the user can specify the log file.  I'd like to pass this parameter to
the Logger which uses a FileAppender.  I am not sure how to do this in log4j 2.

Thanks,
Arwen

This electronic mail message contains information that (a) is or 
may be CONFIDENTIAL, PROPRIETARY IN NATURE, OR OTHERWISE 
PROTECTED 
BY LAW FROM DISCLOSURE, and (b) is intended only for the use of 
the addressee(s) named herein.  If you are not an intended 
recipient, please contact the sender immediately and take the 
steps necessary to delete the message completely from your 
computer system.

Not Intended as a Substitute for a Writing: Notwithstanding the 
Uniform Electronic Transaction Act or any other law of similar 
effect, absent an express statement to the contrary, this e-mail 
message, its contents, and any attachments hereto are not 
intended 
to represent an offer or acceptance to enter into a contract and 
are not otherwise intended to bind this sender, 
barnesandnoble.com 
llc, barnesandnoble.com inc. or any other person or entity.
Arwen Pond | 6 Aug 19:42 2014

Set the log level based on command line args

I am investigating migrating from log4j 1 to log4j 2.  A pattern that I have in many of my applications is
setting the log level based on command line arguments.  So if the -v (verbose) option is passed I set the log
level to Info.  The default is set to warn.
    if (line.hasOption("v"))
    {
      logger.setLevel(Level.INFO);
    }

    if (line.hasOption("d"))
    {
      logger.setLevel(Level.DEBUG);
    }

In the world of log4j 2, what is the recommended way to accomplish this?

Thanks,
Arwen

This electronic mail message contains information that (a) is or 
may be CONFIDENTIAL, PROPRIETARY IN NATURE, OR OTHERWISE 
PROTECTED 
BY LAW FROM DISCLOSURE, and (b) is intended only for the use of 
the addressee(s) named herein.  If you are not an intended 
recipient, please contact the sender immediately and take the 
steps necessary to delete the message completely from your 
computer system.

Not Intended as a Substitute for a Writing: Notwithstanding the 
Uniform Electronic Transaction Act or any other law of similar 
effect, absent an express statement to the contrary, this e-mail 
(Continue reading)


Gmane