use-parent-handlers="false" does not work - jboss-eap-7

I hope I am doing wrong and can say what it is.
I am Using JBoss EAP 7.0.4.
I have a problem with logging, that although i defined use-parent-handers="false" every log is also printed in the root logger (=console).
This ist form my standalone.xml:
<profile>
<subsystem xmlns="urn:jboss:domain:logging:3.0">
<console-handler name="CONSOLE">
<level name="TRACE"/>
<formatter>
<named-formatter name="COLOR-PATTERN"/>
</formatter>
</console-handler>
<periodic-rotating-file-handler name="FILE" autoflush="true">
<formatter>
<named-formatter name="PATTERN"/>
</formatter>
<file relative-to="jboss.server.log.dir" path="server.log"/>
<suffix value=".yyyy-MM-dd"/>
<append value="true"/>
</periodic-rotating-file-handler>
<periodic-rotating-file-handler name="TEST" autoflush="true">
<formatter>
<named-formatter name="PATTERN"/>
</formatter>
<file relative-to="jboss.server.log.dir" path="test.log"/>
<suffix value=".yyyy-MM-dd"/>
<append value="true"/>
</periodic-rotating-file-handler>
<logger category="org.jboss.modules" use-parent-handlers="false">
<level name="TRACE"/>
<handlers>
<handler name="TEST"/>
</handlers>
</logger>
<root-logger>
<level name="INFO"/>
<handlers>
<handler name="CONSOLE"/>
<handler name="FILE"/>
</handlers>
</root-logger>
<formatter name="PATTERN">
<pattern-formatter pattern="%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%c] (%t) %s%e%n"/>
</formatter>
<formatter name="COLOR-PATTERN">
<pattern-formatter pattern="%K{level}%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%e%n"/>
</formatter>
</subsystem>
After adding this logger:
<logger category="org.jboss.modules" use-parent-handlers="false">
<level name="TRACE"/>
<handlers>
<handler name="TEST"/>
</handlers>
</logger>
every trace is also printed to console.
After removing this logger again, console prints as expected.
As far as I understand this would be normal behaviour if I did not defined use-parent-handlers="false" but I did and I do not understand why it is not working.
If you need further information, feel free to ask.
Thanks in advance.

You should be able to execute the following CLI commands and see trace logging not appear on the console.
/subsystem=logging/periodic-rotating-file-handler=TEST:add(named-formatter=PATTERN, suffix=".yyyy-MM-dd", append=true, autoflush=true, file={relative-to=jboss.server.log.dir, path=test.log})
/subsystem=logging/logger=org.jboss.modules:add(use-parent-handlers=false, handlers=[TEST], level=TRACE)
:reload
The :reload isn't required, but will reload the server so it will show the logging you'd want to see.

Related

how to enable additional login for http connector in JBoss EAP 6

We have two java application running on the jboss 6.4 and one is calling to other using http call. it is working fine but few times in day conenction is failing with below error :
CAUSED BY:
java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:209)
at java.net.SocketInputStream.read(SocketInputStream.java:141)
at sun.security.ssl.InputRecord.readFully(InputRecord.java:465)
at sun.security.ssl.InputRecord.read(InputRecord.java:503)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:973)
at sun.security.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:930)
Applcaction 1 is taking the request from the oracle queue and as per the asynchronous call sending the http call to applcation 2 . We would like to debug the issue of the failure to find the more info . how we can enable additional login between Htppconnector and httpclient ? or what could be the possible reason of Connection reset ?
We are using standalone-full.xml and it has below login level ::
<logger category="com.arjuna">
<level name="WARN" />
</logger>
<logger category="org.apache.tomcat.util.modeler">
<level name="WARN" />
</logger>
<logger category="org.jboss.as.config">
<level name="DEBUG" />
</logger>
<logger category="sun.rmi">
<level name="WARN" />
</logger>
<logger category="jacorb">
<level name="WARN" />
</logger>
<logger category="jacorb.config">
<level name="ERROR" />
</logger>
<root-logger>
<level name="INFO" />
<handlers>
<handler name="CONSOLE" />
<handler name="FILE" />
</handlers>
</root-logger>
--------
<subsystem xmlns="urn:jboss:domain:web:2.2"
default-virtual-server="default-host" native="false">
<connector name="http" protocol="HTTP/1.1" scheme="http"
socket-binding="http" />
<connector name="HTTPS" protocol="HTTP/1.1" scheme="https"
socket-binding="https" secure="true">
----------------------
</connector>
<virtual-server name="default-host"
enable-welcome-root="true">
<alias name="localhost" />
</virtual-server>
<valve name="AccessLog" module="org.jboss.as.web"
class-name="org.apache.catalina.valves.AccessLogValve" enabled="true">
<param param-name="prefix"
param-value="${jboss.bind.address:xx.xx.xx}_${jboss.host.name:jboss}_access_log." />
<param param-name="suffix" param-value=".log" />
<param param-name="directory" param-value="${jboss.server.log.dir}" />
<param param-name="pattern" param-value="%h %l %u %t %r %s %b %D" />
<param param-name="resolveHosts" param-value="false" />
<param param-name="rotatable" param-value="true" />
</valve>
You can enable access logging by adding it in the web subsystem. It will log all coming requests and their outcomes.
<subsystem xmlns="urn:jboss:domain:web:1.1" default-virtual-server="default-host" native="false">
<connector name="http" protocol="HTTP/1.1" scheme="http" socket-binding="http"/>
<virtual-server name="default-host" enable-welcome-root="true">
<alias name="localhost"/>
<alias name="example.com"/>
<access-log pattern="%a %t %H %p %U %s " >
<directory relative-to="jboss.server.log.dir" />
</access-log>
</virtual-server>
</subsystem>

How to log request and response in soap message format while consuming a soap service

Consuming a soap web service.
Report report = new Report()
report.setUsername("test");
report.setPassword("test123");
System.out.println("Going to make the request .....");
logger.info("Request :" +report)
SetReportResponse response =(SetReportResponse) soapConnector.callWebService("http://10.88.12.16/ws/_REQUEST_FEEDBACK/services/Feedback.FeedbackHttpSoap11Endpoint/", report);
logger.info(response.getReturn());
How can I log the request and response in xml format, exactly how it send to the client. Just like below
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://ws.mogk">
<soapenv:Header/>
<soapenv:Body>
.
.
.
.
.
Has suggested in one post add the below entries in application properties, but it didnt help.
logging.level.org.springframework.web=DEBUG
logging.level.org.springframework.ws.client.MessageTracing.sent=DEBUG
logging.level.org.springframework.ws.server.MessageTracing.sent=DEBUG
logging.level.org.springframework.ws.client.MessageTracing.received=TRACE
logging.level.org.springframework.ws.server.MessageTracing.received=TRACE
Using Spring Boot 2 and log4j2
Log4j2.xml - Enabled org.springframework.ws.client.MessageTracing
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
<Properties>
<Property name="log-path">D:\Logs/MA</Property>
>
</Properties>
<Appenders>
<Console name="CONSOLE_APPENDER" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n" />
</Console>
<!-- this file will have all the logging done with log.info others will
not come in this file due to usage of the filters -->
<RollingFile append="true" name="FILE_APPENDER_IFNO"
fileName="${log-path}/mk-trace.log" filePattern="${log-path}/msa-trace-%d{yyyy-MM-dd}-%i.log">
<PatternLayout>
<pattern>%d %p [%t] %m%n</pattern>
</PatternLayout>
<Policies>
<!-- <OnStartupTriggeringPolicy /> -->
<SizeBasedTriggeringPolicy size="10 MB" />
<!-- <TimeBasedTriggeringPolicy interval="24" modulate="true" /> -->
</Policies>
<Filters>
<!-- First deny warn, error and fatal messages -->
<ThresholdFilter level="warn" onMatch="DENY"
onMismatch="NEUTRAL" />
<ThresholdFilter level="error" onMatch="DENY"
onMismatch="NEUTRAL" />
<ThresholdFilter level="fatal" onMatch="DENY"
onMismatch="NEUTRAL" />
<!-- Then accept info, warn, error, fatal and deny debug/trace -->
<ThresholdFilter level="info" onMatch="ACCEPT"
onMismatch="DENY" />
</Filters>
</RollingFile>
<!-- this fill will contain all the errors like log.error -->
<RollingFile append="false" name="FILE_APPENDER_ERROR"
fileName="${log-path}/mk-error.log" filePattern="${log-path}/msa-error-%d{yyyy-MM-dd}-%i.log">
<PatternLayout>
<pattern>%d %p [%t] %m%n</pattern>
</PatternLayout>
<Policies>
<OnStartupTriggeringPolicy />
<SizeBasedTriggeringPolicy size="10 MB" />
<TimeBasedTriggeringPolicy interval="24"
modulate="true" />
</Policies>
</RollingFile>
</Appenders>
<Loggers>
<Root level="trace">
<AppenderRef ref="FILE_APPENDER_IFNO" level="INFO" />
<AppenderRef ref="FILE_APPENDER_ERROR" level="ERROR" />
<AppenderRef ref="CONSOLE_APPENDER" level="INFO" />
</Root>
<logger name="org.springframework.ws.client.MessageTracing">
<level value="TRACE" />
<appender-ref ref="console" />
<appender-ref ref="file" />
</logger>
<!-- Spring Webservice XML -->
<logger name="org.springframework.ws.server.MessageTracing.received">
<level value="TRACE" />
<appender-ref ref="console" />
<appender-ref ref="file" />
</logger>
<logger name="org.springframework.ws.server.MessageTracing.sent">
<level value="TRACE" />
<appender-ref ref="console" />
<appender-ref ref="file" />
</logger>
</Loggers>
<!-- TRACE->DEBUG->INFO->WARN->ERROR->FATAL -->
</Configuration>

log4j - not writing to file when using executable jar

I'm using Spring Boot and creating an executable jar file. We have log4j2 configured. When the app starts, it creates the log file as designated in the log4j2-spring.xml file but never writes to it. Hot changes to the log level in the config file also does not work...expected I guess since it's not writing to the file anyway. My config is below. All paths have been double and triple checked and appear proper.
It should be noted that spring apparently has some log configured. In the jar file, I have removed the xml config to ensure it's not reading from anything in the jar file...yet logging is happening to the console but never in the file...and, again, changing the level has no effect.
FILE: log4j2-spring.xml
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN" monitorInterval="30">
<Properties>
<Property name="PID">????</Property>
<property name="name">AddressValidation</property>
<Property name="log.file.path">/opt/java/logs</Property>
<Property name="log.file.archive.path">/opt/java/logs/archive</Property>
<Property name="log.file">AddressValidation</Property>
<Property name="log.file.size">500MB</Property>
<Property name="log.file.max-files">10</Property>
<Property name="log.level">ERROR</Property>
<Property name="LOG_PATTERN">%d{yyyy-MM-dd'T'HH:mm:ss.SSSZ} %p %m%n</Property>
</Properties>
<Appenders>
<RollingFile name="file" fileName="${log.file.path}/${log.file}.log" filePattern="${log.file.archive.path}/${log.file}-%d{yyyy-MM-dd}-%i.log.gz">
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} %5p ${sys:PID} --- [%t] %c{1}(%M:%L) : %m%n%wEx" />
<Policies>
<TimeBasedTriggeringPolicy /><!-- Rotated everyday -->
<SizeBasedTriggeringPolicy size="${log.file.size}" /> <!-- Or every 100 MB -->
</Policies>
<DefaultRolloverStrategy max="${log.file.max-files}"/>
</RollingFile>
<Console name="Console" target="SYSTEM_OUT" follow="true">
<PatternLayout pattern="%clr{%d{yyyy-MM-dd HH:mm:ss.SSS}}{faint} %clr{%5p} %clr{${sys:PID}}{magenta} %clr{---}{faint} %clr{[%t]}{faint} %clr{%c{1}(%M:%L)}{cyan} %clr{:}{faint} %m%n%wEx" />
</Console>
</Appenders>
<Loggers>
<AsyncLogger name="org.hibernate.validator.internal.util.Version" level="warn" additivity="false" />
<AsyncLogger name="org.apache.coyote.http11.Http11NioProtocol" level="warn" additivity="false" />
<AsyncLogger name="org.apache.tomcat.util.net.NioSelectorPool" level="warn" additivity="false" />
<AsyncLogger name="org.apache.catalina.startup.DigesterFactory" level="error" additivity="false" />
<AsyncLogger name="org.springframework.web" level="error" />
<AsyncLogger name="com.netflix" level="error" additivity="false" />
<AsyncLogger name="org.springframework.cloud" level="error" additivity="false" />
<AsyncLogger name="com.abc.addressvalidation" level="ERROR">
<AppenderRef ref="file"/>
</AsyncLogger>
<Root level="ERROR">
<AppenderRef ref="Console"/>
<AppenderRef ref="file" />
</Root>
</Loggers>
</Configuration>
I call it as follows:
java -Dlog4j.configurationFile=C:\test\config\log4j2-spring.xml -jar AddressValidation-0.0.1-SNAPSHOT.jar
I'm running out of ideas here. I find lots of info here on StackOverflow on this. It's all pretty much the same advice that I think I'm following.

How to I get the error stack trace to appera in my JBoss server log?

I have a Spring 3.2.11.RELEASE running on Wildfly 10. On a particular page of my application, this is being printed to my browser
{"status":"failure","exception":"ClassCastException","exceptionMessage":"java.lang.Boolean cannot be cast to java.util.List","errorMessage":"java.lang.Boolean cannot be cast to java.util.List"}
I would like to figure out what the stack trace of what is causing this, but it is not listed in my $JBOSS_HOME/standalone/log/server.log file. How do I make it appear? Below is my logging configuration in my $JBOSS_HOME/standalone/configuration/standalone.xml file …
<subsystem xmlns="urn:jboss:domain:logging:3.0">
<console-handler name="CONSOLE">
<level name="INFO"/>
<formatter>
<named-formatter name="COLOR-PATTERN"/>
</formatter>
</console-handler>
<periodic-rotating-file-handler name="FILE" autoflush="true">
<formatter>
<named-formatter name="PATTERN"/>
</formatter>
<file relative-to="jboss.server.log.dir" path="server.log"/>
<suffix value=".yyyy-MM-dd"/>
<append value="true"/>
</periodic-rotating-file-handler>
<logger category="com.arjuna">
<level name="DEBUG"/>
</logger>
<logger category="org.apache.tomcat.util.modeler">
<level name="DEBUG"/>
</logger>
<logger category="org.jboss.as.config">
<level name="DEBUG"/>
</logger>
<logger category="sun.rmi">
<level name="DEBUG"/>
</logger>
<logger category="com">
<level name="DEBUG"/>
</logger>
<logger category="org">
<level name="DEBUG"/>
</logger>
<logger category="org.hibernate">
<level name="DEBUG"/>
</logger>
<root-logger>
<level name="INFO"/>
<handlers>
<handler name="CONSOLE"/>
<handler name="FILE"/>
</handlers>
</root-logger>
<formatter name="PATTERN">
<pattern-formatter pattern="%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%c] (%t) %s%e%n"/>
</formatter>
<formatter name="COLOR-PATTERN">
<pattern-formatter pattern="%K{level}%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%e%n"/>
</formatter>
</subsystem>
I have defined no log4j.proeprties or log4j.xml in my application so I’m not sure how else to configure getting a stack trace to appear in my logs.

Spring performance interceptor not logging with log4j2

I have used spring aop t to log time of service execution but it's not logging. i am not getting any exception as well.
help me to solve this issue whether it's problem in log4j2 configuration or it's wrong with point cut expression.
Following is my application-context.xml
<bean id="perfMonitor"
class="org.springframework.aop.interceptor.PerformanceMonitorInterceptor">
</bean>
<aop:config proxy-target-class="true">
<aop:pointcut id="allServiceMethods" expression="execution(* com.lfr.services..*.*(..))"
/>
<aop:advisor pointcut-ref="allServiceMethods" advice-ref="perfMonitor"
order="1" />
</aop:config>
following is my log4j2.xml
<?xml version="1.0" encoding="UTF-8"?>
<configuration status="debug">
<appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %level - %m%n%ex%n" />
</Console>
<File name="log4jdbc_file" fileName="d:/logs/log4jdbc21.log">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %level - %m%n%ex%n" />
</File>
</appenders>
<loggers>
<logger name="log4jdbc.log4j2" level="info" additivity="false">
<MarkerFilter marker="LOG4JDBC_NON_STATEMENT" onMatch="DENY"
onMismatch="NEUTRAL" />
<appender-ref ref="log4jdbc_file" />
</logger>
<logger
name="org.springframework.aop.interceptor.PerformanceMonitorInterceptor"
level="trace">
<appender-ref ref="Console" />
</logger>
<root level="trace">
<appender-ref ref="Console" />
</root>
</loggers>
</configuration>

Resources