You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by davidgo <dg...@riafinancial.com> on 2014/12/23 22:08:11 UTC

CXF Logging (log4j) shows in Console, but not in File

Hello,
I have been able to get log4j working and my cxf service working.
I get my coded log entries AND the soap messages in the console. 
However, I only get my coded log entries in the log file and NOT the soap
messages.
Anyone have an idea of what I am missing to make the soap messages show in
the log file too?
I am using cxf 2.7.12 and log4j2.

Right now I made a simple test service to try and debug this.  Here is what
I have:
---------------------------
I am starting my server with:
		TestServicePortTypeImpl implementor = new TestServicePortTypeImpl();
		String address = "http://localhost:"
				+ Settings.getString("WEB_SERVICE_PORT") + "/TestService";
		Endpoint.publish(address, implementor);

---------------------------
I am running my service in Eclipse with these arguments:

-Dcxf.config.file=cxf_config.xml
-Dorg.apache.cxf.Logger=org.apache.cxf.common.logging.Log4jLogger

---------------------------
In my cxf.xml config file I have:
    <cxf:bus>
        <cxf:features>
            <cxf:logging/>
        </cxf:features>
    </cxf:bus> 

---------------------------
In my log4j2.xml config file I have:
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
	<Appenders>
		<Console name="Console" target="SYSTEM_OUT">
			<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} -
%msg%n"/>
		</Console>
		<File name="File" fileName="logs/testservice1.log">
			<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} -
%msg%n"/>
		</File>
	</Appenders>
	<Loggers>
		<Root level="all">
			<AppenderRef ref="Console"/>
			<AppenderRef ref="File"/>
		</Root>
	</Loggers>
</Configuration>
---------------------------

I know the service is starting and answering calls.
I know the cxf config is getting picked up because the soap message logging
to the console showed up when I added that.
I know the log4j config is getting picked up and that messages are logging
there because I see them in the file.
I am guessing there is some small piece of config I am missing, but I have
followed all the doc for how to set up cxf logging and log4j, and the
problem still persists.

Thanks,
David





--
View this message in context: http://cxf.547215.n5.nabble.com/CXF-Logging-log4j-shows-in-Console-but-not-in-File-tp5752695.html
Sent from the cxf-user mailing list archive at Nabble.com.

RE: CXF Logging (log4j) shows in Console, but not in File

Posted by Andrei Shakirin <as...@talend.com>.
Hi,

I don't see any obvious problem in you configuration.
Could you set status="trace" in order to see a bit more what happens during configuration process?

Regards,
Andrei.

> -----Original Message-----
> From: davidgo [mailto:dgo@riafinancial.com]
> Sent: Dienstag, 23. Dezember 2014 22:08
> To: users@cxf.apache.org
> Subject: CXF Logging (log4j) shows in Console, but not in File
> 
> Hello,
> I have been able to get log4j working and my cxf service working.
> I get my coded log entries AND the soap messages in the console.
> However, I only get my coded log entries in the log file and NOT the soap
> messages.
> Anyone have an idea of what I am missing to make the soap messages show in
> the log file too?
> I am using cxf 2.7.12 and log4j2.
> 
> Right now I made a simple test service to try and debug this.  Here is what I
> have:
> ---------------------------
> I am starting my server with:
> 		TestServicePortTypeImpl implementor = new
> TestServicePortTypeImpl();
> 		String address = "http://localhost:"
> 				+ Settings.getString("WEB_SERVICE_PORT") +
> "/TestService";
> 		Endpoint.publish(address, implementor);
> 
> ---------------------------
> I am running my service in Eclipse with these arguments:
> 
> -Dcxf.config.file=cxf_config.xml
> -Dorg.apache.cxf.Logger=org.apache.cxf.common.logging.Log4jLogger
> 
> ---------------------------
> In my cxf.xml config file I have:
>     <cxf:bus>
>         <cxf:features>
>             <cxf:logging/>
>         </cxf:features>
>     </cxf:bus>
> 
> ---------------------------
> In my log4j2.xml config file I have:
> <?xml version="1.0" encoding="UTF-8"?>
> <Configuration status="WARN">
> 	<Appenders>
> 		<Console name="Console" target="SYSTEM_OUT">
> 			<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-
> 5level %logger{36} - %msg%n"/>
> 		</Console>
> 		<File name="File" fileName="logs/testservice1.log">
> 			<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-
> 5level %logger{36} - %msg%n"/>
> 		</File>
> 	</Appenders>
> 	<Loggers>
> 		<Root level="all">
> 			<AppenderRef ref="Console"/>
> 			<AppenderRef ref="File"/>
> 		</Root>
> 	</Loggers>
> </Configuration>
> ---------------------------
> 
> I know the service is starting and answering calls.
> I know the cxf config is getting picked up because the soap message logging to
> the console showed up when I added that.
> I know the log4j config is getting picked up and that messages are logging there
> because I see them in the file.
> I am guessing there is some small piece of config I am missing, but I have
> followed all the doc for how to set up cxf logging and log4j, and the problem
> still persists.
> 
> Thanks,
> David
> 
> 
> 
> 
> 
> --
> View this message in context: http://cxf.547215.n5.nabble.com/CXF-Logging-
> log4j-shows-in-Console-but-not-in-File-tp5752695.html
> Sent from the cxf-user mailing list archive at Nabble.com.