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

Sebastian Oerding commented on LOG4J2-290:
------------------------------------------

Hi,

I tried to create a test for a few hours. However I struggled to create an own 
appender and my boss won't be very happy if I use a whole day to write a Junit 
tests ... .

However I struggled with writing the tests as the generation of the 
Log4j2Plugins.dat seems to be broken a bit and furthermore there are new 
problems comparing beta7 with beta6.

1. I invoked the PluginManager.main(new String[] { ".\\src/config", 
"log4j2.socket" }); in a class that defines a Logger. Then the generated 
Log4j2Plugins.dat only contains all the elements of log4j2 but not my own 
implementation of an appender. When I remove the Logger definition from the 
test class such that no Log4j2 is invoked before the test executes the 
generated Log4j2Plugins.dat contains only my appender as expected.

2. I named my appender MyAppender (the class name and the defined name 
attribute in @Plugin(name = "MyAppender", ...). However in the 
Log4j2Plugins.dat the name is completely changed to lowercase. However using 
that name in different spellings ("MyAppender", "myappender" and "MyAppender") 
resulted in an "Unable to locate Appender APPENDER_NAME for logger".

3. I finally managed to get it working by using the Log4j2Plugins.dat created 
with log4j2 beta6, renaming the MyAppender class and putting it into the 
directory accordingly to the copied Log4j2Plugins.dat

I will try to add the source code. Is there any possibility adding source 
without putting it into a comment? otherwise see the next comment for the code.
                
> System.out mixed up with other input streams
> --------------------------------------------
>
>                 Key: LOG4J2-290
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-290
>             Project: Log4j 2
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 2.0-beta7
>         Environment: Windows 7 64 bit, Eclipse 4.2.1, java JDK 1.6.0.43
>            Reporter: Sebastian Oerding
>
> Hi,
> I've noticed a strange behaviour which seems to be a bug in log4j 2. 
> Unfortunately I'm not totally sure if the problem was caused by my code, 
> log4j or the JDK.
> I've written my own appender which works as expected. I've have implemented 
> some stuff to send log events over the network (the socket appender does not 
> fit my needs).
> I use log4j 2 to get the log events in my own appender. There I filter the 
> events and send them over the network using java.net.sockets.
> For unit tests I simulate a client and server in the same JVM using sockets.
> Furthermore the console appender is activated in the log4j2.xml. As the 
> logging is done asynchronously the client are threads awaiting log events 
> endlessly until the whole client is stopped.
> 1. Now, when I output something with System.out.println sometimes it seems to 
> be forwarded to other appenders. Soory but at the moment I lack a better 
> description.
> 2. I had the case that something was logged on the server using 
> LOG.debug(...) (where LOG was my Logger instance). However this log seem to 
> never reach my appender but it appears at the client's socket input stream.
> Hence either the input streams got somehow mixed up or due to a mysterious 
> reason data written to system.out is also written to the server's socket 
> output stream (and received on the client) or directly written to the 
> client's input stream.
> I would not claim that my code has no bugs (actually I found zombie threads 
> due to this) but I can not imagine how I should have caused such problems as 
> I am working nowhere with System.in / System.out besides invoking 
> System.out.println. This problems occurred only rarely but was reproducible.
> Unfortunately I can not provide the complete code to reproduce this problem.
> I also feel unfortunate for the vague description.
> However if you have concrete questions, I may be able to be more precise or 
> to provide code snippets.

--
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: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to