How to define custom log level in WildFly 10 - wildfly

In standalone.xml we have the following:
<root-logger>
<level name="INFO"/>
<handlers>
<handler name="CONSOLE"/>
<handler name="FILE"/>
</handlers>
</root-logger>
How can I add something like:
<level name="MYLEVEL"/>
Is this possible to do in WildFly 10 Server?

The standard java.util.logging.Level used by the LogManager allows you to pass an integer value of your custom level. For example, if your MYLEVEL has a value of 2000 you can use the number instead of the name.
<root-logger>
<level name="2000"/>
<handlers>
<handler name="CONSOLE"/>
<handler name="FILE"/>
</handlers>
</root-logger>
To use a custom level by the level name you have to include that binary in the boot class path.

Related

Jboss 7.1 logging filter in standalone.xml

In Jboss 7.1 how to configure standalone.xml to log only INFO level
<periodic-rotating-file-handler name="FILE">
<level name="INFO"/>
<formatter>
<pattern-formatter pattern="%z{utc}%d{MM/dd/yyyy HH:mm:ss,SSS} %-5p [%c] %s%E%n"/>
</formatter>
<file relative-to="jboss.server.log.dir" path="server.log"/>
<suffix value=".yyyy-MM-dd"/>
<append value="true"/>
</periodic-rotating-file-handler>
By default root loggers are configured to print INFO level logs. If you have to change log level for any other logger category or log handlers. Just add below tag to that particular category or handler.
<level name="INFO"/>
If you have log only INFO level logs, you will have t0 implement filter something like
<filter-spec value="(levels(INFO))"/>

Perform hourly logrotate on JBoss EAP 7 access log

By default, JBoss EAP 7 rotates its access log daily.
I needed to set this to like, HOURLY.
Reason:
We have a script that automatically downloads the rotated access log file.
But doing this ^ would greatly increase CPU usage (because the access log at the end of the day is VERY large, and our system's performance is unfortunately reduced while downloading it)
What I know is that, in the standalone.xml, I've tried adding the one below to make the JBoss server log to rotate every hour.
<suffix value=".yyyy-MM-dd-HH"/>
But this method does not apply to access log (because its settings is weirdly placed in a different part of the standalone.xml)
I've tried experimenting with the access-log tags to have any of the following. But it just throws an error.
<access-log suffix=".yyyy-MM-dd-HH" ...
<access-log rotate="hourly" ...
...and i can't seem to find a VERY detailed guide about standalone.xml of JBoss EAP 7. I'm thinking that I should use a tag value for the access-log part.
Please help. Does anyone know of a way to do this? :(
System specs
Oracle Linux 6.9
JBoss EAP 7
Thanks and best regards.
Try following
<subsystem xmlns="urn:jboss:domain:logging:3.0">
...(snip)...
<!-- size-based log rotation -->
<size-rotating-file-handler name="access-log" autoflush="true">
<formatter>
<named-formatter name="access-log-formatter"/>
</formatter>
<file relative-to="jboss.server.log.dir" path="access.log"/>
<rotate-size value="10m"/>
<max-backup-index value="10"/>
<append value="true"/>
</size-rotating-file-handler>
<! -- or custom interval (hourly) log rotation
<periodic-rotating-file-handler name="access-log-custom" autoflush="true">
<formatter>
<named-formatter name="access-log-formatter"/>
</formatter>
<file relative-to="jboss.server.log.dir" path="access.log"/>
<suffix value=".yyyy-MM-dd-HH"/>
<append value="true"/>
</periodic-rotating-file-handler>
--->
...(snip)...
<logger category="io.undertow.accesslog" use-parent-handlers="false">
<handlers>
<handler name="access-log"/>
</handlers>
</logger>
...(snip)...
<formatter name="access-log-formatter">
<pattern-formatter pattern="%s%n"/>
</formatter>
</subsystem>
...(snip)...
<subsystem xmlns="urn:jboss:domain:undertow:3.1" statistics-enabled="true">
...(snip)...
<server name="default-server">
<http-listener name="default" socket-binding="http" redirect-socket="https" record-request-start-time="true"/>
<host name="default-host" alias="localhost">
...(snip)...
<access-log use-server-log="true" pattern="%h %l %u %t "%r" %s %b "%{i,Referer}" "%{i,User-Agent}" "%{i,COOKIE}" "%{o,SET-COOKIE}" %S "%I" %T"/>
...(snip)...
</host>
</server>
...(snip)...
</subsystem>

WELD-000119 Not generating any bean definitions from "Clazz" because of underlying class loading error

I'm trying to run Arquillian tests inside my JBoss EAP server container.
When i run them, i'm getting the following info messages:
16:49:48,648 INFO [org.jboss.weld.ClassLoading] (MSC service thread 1-1) WELD-000119 Not generating any bean definitions from package.ChartofaccountDAO because of underlying class loading error
16:49:48,768 INFO [org.jboss.weld.ClassLoading] (MSC service thread 1-1) WELD-000119 Not generating any bean definitions from package.ChartofaccountDAOImpl because of underlying class loading error
I think this is the cause because all my CDI injections aren't being processed.
I tried enabling DEBUG in this class to get more information, i've changed standalone.xml to:
<root-logger>
<level name="DEBUG"/>
<handlers>
<handler name="CONSOLE"/>
<handler name="FILE"/>
</handlers>
</root-logger>
But i still can only see INFO log records.
Found the solution, i had to enable logger in the class and in the console-handler:
<console-handler name="CONSOLE">
<level name="DEBUG"/>
<formatter>
<named-formatter name="COLOR-PATTERN"/>
</formatter>
</console-handler>
<logger category="org.jboss.weld.ClassLoading">
<level name="DEBUG"/>
</logger>

how to send mail for log level ERROR in JBoss EAP6.1.0 (AS 7.2.0 Final Redhat 8)

Hi We are using JBoss EAP 6.1.0 for our project, i am trying to find a way to configure sending emails for loglevel ERROR in standalone.xml but i didn't fine any documentation which provides some example i added the below configuration to my standalone.xml but i am getting parsing exception after that.
Here is my code:
<subsystem xmlns="urn:jboss:domain:logging:1.2">
<console-handler name="CONSOLE">
[Some Code Here]
</console-handler>
<custom-handler name="EMAIL" class="org.apache.log4j.net.SMTPAppender" module="org.apache.log4j">
<level name="ERROR"/>
<formatter>
<pattern-formatter pattern="%d %-5p [%c] %m%n"/>
</formatter>
<properties>
<property name="BufferSize" value="10"/
<property name="SMTPHost" value="localhost"/>
<property name="From" value="sviswanadha#corelogic.com"/>
<property name="To" value="sviswanadha#corelogic.com"/>
<property name="Subject" value="SWS Error Log"/>
</properties>
</custom-handler>
<periodic-rotating-file-handler name="FILE">
<formatter>
<pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
</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="WARN"/>
</logger>
<logger category="org.apache.tomcat.util.modeler">
<level name="WARN"/>
</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"/>
<handler name="EMAIL"/>
</handlers>
</root-logger>
</subsystem>
Exception I am getting:
JBAS014789: Unexpected element '{urn:jboss:domain:logging:1.2}handler-ref' encountered
Help in providing suggestions/solution is much appreciated.
JBoss AS 7 no longer uses log4j. It uses jboss-logging which seems to delegate to ava.util.logging.Handlers see also https://github.com/jboss-logging/jboss-logmanager/tree/master/src/main/java/org/jboss/logmanager/handlers.
Maybe you already have the answer, but your xml is not valid.
<properties>
<property name="BufferSize" value="10"/ <--- missing character
<property name="SMTPHost" value="localhost"/>
<property name="From" value="sviswanadha#corelogic.com"/>
<property name="To" value="sviswanadha#corelogic.com"/>
<property name="Subject" value="SWS Error Log"/>
</properties>

Is there a way to log queries on Neo4J like Hibernate?

So, here is the scenario:
I have Neo4J server running locally with some data in it
I have a web app using spring-data-neo4j
The following code is based on the example code Cineasts:
public interface CrewRepository extends GraphRepository<Crew> {
Iterable<Crew> findByNameLike(String name);
#Query("start thinker=node({0}) match thinker-[:crews]-crews return crews")
Set<Crew> findByThinker(Long thinkerId);
}
No news here. The problem is: the query findByNameLike doesn't work whereas the findByThinker does.
I have modified my log configuration file many times - final version is the one below - but, doesn't matter what I try, I can't see any queries being logged - either on my log file or on the server.
<logger name="org.neo4j">
<level value="DEBUG" />
<appender-ref ref="console" />
</logger>
<logger name="org.springframework.data.neo4j">
<level value="DEBUG" />
<appender-ref ref="console" />
</logger>
<root>
<priority value="error" />
<appender-ref ref="console" />
</root>
All I want is the log the queries so I can see if it's a bug on spring-data-neo4j or if I'm missing something... I have looked through the documentation of both, code examples and couldn't find anything that specific.
Any help? Thank you!
You can enable query logging by adding the following lines to your log4j.xml:
<logger name="org.springframework.data.neo4j.support.query">
<level value="debug" />
</logger>
If anyone lands here looking for how to log queries when Neo4j Server is accessed remotely over the REST API, use
<logger name="org.springframework.data.neo4j.rest.SpringRestCypherQueryEngine">
<level value="debug" />
</logger>
If you're using Spring Data Neo4j and want to see the derived queries corresponding to your DAO methods,
<logger name="org.springframework.data.neo4j.repository.query.DerivedCypherRepositoryQuery">
<level value="debug" />
</logger>