how to Supress warning EJBTHREE-1337:do not get webservice context property - java

im new to webservices.i ran a sample webservice(Jboss5.0.1,jdk 6) from java client. i got this warning. but application runs properly.when i searched about this warning i came to know that we dont need to worry about this. but is there any way to hide this from log?
[StatelessBeanContext] EJBTHREE-1337: do not get WebServiceContext property from stateless bean context, it should already have been injected
Thanks in advance.

http://idevone.wordpress.com/2009/09/14/howto-suppress-ejbthree-1337-warning/:
The problem however is that the
warning clutters the log file and
makes debugging harder than needed. It
is easy to suppress it though and I
will show you how.
First, locate jboss-log4j.xml file which should be found under
${JBOSS_HOME}/server/default/conf. If you are using a runtime
configuration other than default, locate the file under configuration
that you actually use. This file is used to configure logging output
of the JBoss.
Inside the file search for “Limit categories” – you should find a list
of definitions. Edit it to look something like this:
<!-- ================ -->
<!-- Limit categories -->
<!-- ================ -->
<!-- Suppress EJBTHREE-1337 warning -->
<category name="org.jboss.ejb3.stateless.StatelessBeanContext">
<priority value="ERROR"/>
</category>
You are basically telling JBoss to suppress any WARN or lower messages
from the class that generates those warnings. Now just restart JBoss
and the warning should disappear.

Related

How to disable request-level logging with the AWS Java SDK?

I'm trying to disable request level logging by the AWS Java SDK with Tomcat 8 on Linux. It's a fresh installation of tomcat 8 and my test servlet (which works) just prints to standard out, which by default goes to /var/log/tomcat8/catalina.out.
I'd like to disable the request level logging like - Sending Request... by the AWS SDK, so I've tried adding the following to my logging config at /usr/share/tomcat8/conf/logging.properties:
log4j.logger.com.amazonaws = WARN
log4j.logger.org.apache.http.wire = WARN
log4j.logger.com.amazonaws.request = WARN
...like the docs say here, but it's still doing the verbose logging. My tomcat startup information shows that the logging.properties file is being used:
org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=/usr/share/tomcat8/conf/logging.properties
Is there anything else I need to do to?
If you are using Logback, instead of Log4J or Java14 logging, put the following in logback.xml:
<configuration>
...
<logger name="org.apache.http.wire" level="WARN"/>
<logger name="com.amazonaws" level="WARN"/>
...
To specify an external logback.xml and using Spring Boot
-Dlogging.config="C:\logback\logback.xml"
or if you are not
-Dlogback.configurationFile=file:///C:/logback/logback.xml
Logback configuration via jvm argument
I had the same issue, none of the above helped actually.
Creating a logback.xml and putting it on classpath with below config fixed it:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<logger name="org.apache" level="ERROR" />
<logger name="httpclient" level="ERROR" />
</configuration>
Hope it helps the others.
"logging.properties" is the configuration file for Java Util Logging (JUL), witch is a different framework then Log4J. You can try to create a Log4J config file "log4j.properties" in the root of your classpath and insert the code from above: "log4j.logger.com.amazonaws = WARN" .
By Mark
Perhaps I should have been clearer: log4j is not required to control logging in the SDK. The SDK uses Apache Commons Logging, which is, as I already mentioned, an industry standard. Commons Logging is just a dispatch layer to an underlying logging implementation, so that customers can plug in any compliant logging framework and have it work. I used log4j in my examples because it's the one most commonly used, and therefore the most likely to be helpful in this public forum.
If your logging system works with Commons Logging, then you already know how to configure it. If it doesn't, then feel free to turn off Commons Logging altogether by passing the appropriate command-line argument to your JVM, as in my above response. If for some reason you can't change the java command line for your application, then you can use the following snippet in a Main class, to the same effect:
static {
System.setProperty("org.apache.commons.logging.Log",
"org.apache.commons.logging.impl.NoOpLog");
}
Again, to be absolutely clear: the SDK doesn't need log4j. Unfortunately, because all the underlying log implementations are configured differently, this means that we can't tell you exactly how to configure the logging unless we know which implementation your application uses. For that reason, we often use log4j syntax in our examples.
For more information about how Apache Commons Logging works and how to configure it, please read:
http://commons.apache.org/logging/guide.html

How can I change jboss logging level to show which java class I am calling?

Is it possible to set up jboss to show which URL I called, which class I am calling, and what parameters I sent to it?
I set my class log4j.xml to TRACE, but that may not be the right .xml file to change. It didn't seem to do anything. Maybe I'm not looking at the right log? I only see boot, errFile, and server.log.
Thanks for any help.
You may want to enable RequestDumper.
In Jboss 4.x.x it can be found in the file
.../server/[YOUR_CONFIG]/deploy/jboss-web.deployer/server.xml
<!-- Uncomment to enable request dumper. This Valve "logs interesting
contents from the specified Request (before processing) and the
corresponding Response (after processing). It is especially useful
in debugging problems related to headers and cookies."
-->
<Valve className="org.apache.catalina.valves.RequestDumperValve" />

Can't print to console with log4j

My problem is that I want to know how many connections are opened to the oracledb in an oracle datasource pool (oracle.jdbc.pool.OracleDataSource) and I want to print this information to the console using log4j.
I defined my pool in a spring configuration file:
<bean id="dataSource" class="oracle.jdbc.pool.OracleDataSource" >
<property name="dataSourceName" value="ds" />
<property name="URL" value="jdbc:oracle:thin:#something" />
<property name="user" value="user" />
<property name="password" value="password" />
</bean>
I would pass somehow the log's informations in my ojdbc6 or ojdbc14 jars to the console with log4j as I said but my log4j doesn't print anything.
In my log4j.properties I have:
log4j.logger.oracle.jdbc.pool=ALL, jdbc
log4j.appender.jdbc=org.apache.log4j.ConsoleAppender
log4j.appender.jdbc.layout=org.apache.log4j.PatternLayout
log4j.appender.jdbc.layout.ConversionPattern=JDBC | %5p | %d{HH:mm:ss,SSS} > %m - [%l]%n
I don't know if there are these kind of informations in ojdbc bundles, ok and if you know how can I have you're welcome, but my problem is that I can't see any logs. Maybe there aren't any logs at all...
Thank you for your attention.
there is no guarantee oracle uses log4j, you should try to configure java util logging settings. This link seems to suggest oracle uses java util logging. Alternatively you could build a proxy class or extend this class and write your own log4j messages before/after delegating back to the oracle connection pool.
Check this page to initialize the configurator. If you don't initialize it properly log4j wont log messages. Most importantly try to use log.debug, log.warn in the business logic which makes use of oracle objects. Log4j is a just a logging library which you can use through java. Not sure if oracle dumps it via that.
There are other tracing and logging tools if you think its not working fine. My first pointer would be try a simple app in your application to see if your console gets the log4j messages when you run them after using the configurator i mentioned previously.
I found the answer, only some ojdbc bundles are able to print logs.
I have ojdbc6 and ojdbc14 jars and they haven't this ability.
From this link.
When full logging is enabled, it is almost guaranteed that all sensitive information will be exposed in the log files. This is intrinsic to the logging feature. However, only certain JDBC JAR files include the JDBC logging feature. The following JAR files include full logging and should not be used in a sensitive environment:
ojdbc5_g.jar
ojdbc5dms_g.jar
ojdbc6_g.jar
ojdbc6dms_g.jar
The following JAR files include a limited logging capability:
ojdbc5dms.jar
ojdbc6dms.jar
I'm done :P

Specify only some packages to have debug output

I want to log some behavior of my web application which also implements hibernate, spring and so on. When I tried to implement log4j logger from apache I had some troubles.
When I turn on logger it is also debugging hibernate and spring which I don't want. I tried to configure properties file to the specify the package of my project but it does not work.
Here is my code of property file:
log4j.rootCategory=ERROR, O
log4j.category.com.my.package= DEBUG, FILE, O
log4j.appender.FILE=org.apache.log4j.RollingFileAppender
log4j.appender.FILE.File=log/logger.log
log4j.appender.O=org.apache.log4j.ConsoleAppender
.... and some layout
It works when I switch rootCategory = DEBUG but it is also debugging the hibernate and spring as I said.
Yes, you have to specfiy the log level per package:
log4j.logger.org.hibernate=info
log4j.logger.org.springframework=info
log4j.logger.com.yourapplication=debug
Note that you should switch from categories (obsolete) to loggers. So log4j.rootLogger=...
You would need to know the name of the loggers that are actually writing stuff... The simplest way is to set the root category to error:
log4j.rootCategory=ERROR, 0
Then set the level for your logs accordingly:
log4j.com.your.package=DEBUG...
Setting the rootCategory to DEBUG will turn everything to DEBUG, unless you specifically configure a logger otherwise.
B.T.W, this is NOT a hibernate issue, this is related to how you are configuring your logger.

How to turn off logging from SLF4J?

It's a third party application generating huge amounts of log entries on our app server. Like this:
[03.03.10 15:21:57:250 CET] 00000180 FtpProtocolHa I org.slf4j.impl.JCLLoggerAdapter info Close connection : 10.227.10.10 - admin
[03.03.10 15:27:35:209 CET] 00000181 MinaFtpProtoc I org.slf4j.impl.JCLLoggerAdapter info [/10.227.10.10] CLOSED
++++
How do I turn this output from SLF4J off? I've looked in the .war file to find some configuration for SLF4J but nothing. Their website didn't help either.
slf4j is just a funnel to the actual log backend (here overriding jakarta commons logging), which is the one you must configure to get rid of a certain kind of messages. For logback this is the appropriate configuration snippet:
<!-- No Tomcat debug logs -->
<configuration>
...
<logger name="org.apache.catalina.core" level="OFF" />
...
</configuration>
For log4j it is very similar.
Alternatively, download http://www.slf4j.org/dist/slf4j-1.6.4.tar.gz, look in there for slf4j-nop-1.6.4.jar (this is the no-operation logger) and include this in your classpath. When the SLF4J classloader sees this (it looks to see what loggers are in the classpath that it can use), it should stop logging (once you've restarted the app).
At least this way you don't need to mess with the log configuration files...
slf4j is a logging facade for various logging frameworks. That output comes from the Apache Commons Loggin framework adapter, that turns to be another facade. Commons Logging Configuration.
Which logging back-end, e.g. logback, log4j, j.u.l., are you using? You need to configure the backend to filter those messages.
Moreover, the fact that the log messages point to "org.slf4j.impl.JCLLoggerAdapter" indicates that caller location inference is not working correctly. (It should mention the actual caller not JCLLoggerAdapter). This can happen if:
you are using an older version of SLF4J
or
the caller is using a slf4j-like wrapper or has its own homegrown logging API which does not infer caller location properly. See also a relevant SLF4J FAQ entry.
As stated by #sparkyspider answer, you can simply add the slf4j-nop library to your application.
If using Maven, add this to your pom.xml file:
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-nop</artifactId>
<version>1.7.36</version>
</dependency>
</dependencies>
If using Gradle, add this to your build.gradle[.kts] file:
dependencies {
implementation("org.slf4j:slf4j-nop:1.7.36")
}
Search for the following string: level="DEBUG" using your IDE.
You will find that text in a .xml file.
Go there and use level="INFO" instead of level="DEBUG".
The key value is not case-sensitive.
There can be something like:
<root level="info">
...
</root>

Categories

Resources