where does hadoop use yarn.log.file in java src code - hadoop

I see that when starting a NodeManager,
the -Dyarn.log.file=yarn-hadoop-nodemanager-hostname1.log parameter is passed to the NodeManager's main method,
but I can't find where this yarn.log.file is used in java code so that log message can write into the yarn.log.file
wish for some help, thanks

Hadoop uses log4j behind the scenes. Log4j supports different configurable appenders, but when the logging system is configured, you will not see any reference at the file that is just one of many possible appenders ( ie output for the log ). You will probably dig on various log4j configuration file in the hadoop sources looking for *log4j.properties and you will eventually find your referenced file.

Related

Configure Log4j1.x to log asynchronously through property files

I have a large, Spring-based eCommerce framework as a codebase which makes use of pre configured log4j. I can override property values defined in log4j.properties.
I'd like to configure log4j to log asynchronously to console/file, I've attempted to define new/override appenders but am not seeing any output to console and am unsure why.
Is it possible to wrap current log4j into asynchronous calls?

log4j.properties not being picked in Maven based Application

I have searched enough for the below question but could not find the appropriate answer. I would be glad if you can provide me a link if the question already exists.
I am new to Maven and I have created a Maven based application integrated with Hibernate.
Question:
I have a log4j.properties file in "src/java/resources" I have created a Logger instance in one of my classes and tried to print logs however the logs do not get printed on to the console.
Note: I have given the stdout as logs output location.
src/java/resources/ sounds suspicious. The correct location for classpath resources is src/main/resources/. Put the log4j.properties there.
Additionally, it depends on the version you're using. log4j.properties is no longer supported in newer version. In case you use log4j 2, migrate to log4j2.xml.

Websphere Configuration to Avoid Unwated Warnings in SystemOut.log File

I have a problem about logging in SystemOut.log with Websphere. Can someone help me?
I’m getting some unwanted warning written in the SystemOut.log file with Websphere Application Server (WAS). All of the warnings are being generated by OGNL (ognl.NoSuchPropertyException). These exceptions don’t affect the code flow. Hence I need to turn off the logging of these warnings.
Also I have configuration in log4j.properties file to control the filtration of the log messages to error.
It would be a great help if anyone can help what configuration I should do in WAS to avoid logging these warnings.
Regards
You can change the log level from WAS admin console. Servers->WAS->servername->troubleshooting->change log details level
Follow the path and you will see options to filter warning. For example to filer message from com.ibm.ws.*=WARN will filter all but WARN.
Hope this helps.
First, you have to determine what running component, inside your WAS instance, is generating these warning messages. Is it WebSphere itself, logging these warnings internally? or is it your code?
If the source is WebSphere, then perhaps, before setting the logging level to "error" or "severe", you may want to open a PMR with IBM. I never encountered OGNL warnings generated by WebSphere itself. These warnings, then, can be indicative of a problem in your WebSphere installation.
If the source is your application, then the way to cope with this situation depends on how OGNL, internally, is generating these messages:
If OGNL is simply writing log lines to System.out, then there's nothing you can do to suppress these lines.
If OGNL is logging through Log4J, then you should be able to set the log level of the OGNL logger(s) through your log4j.properties. If your log4j.properties changes aren't reflected, then it means that you have a classloading problem of some sort (the log4j.properties file being loaded by a different classloader than the one used to load your web application).
If OGNL is using a different logging framework (such as SLF4J or Commons Logging), then you'll have to read through the documentation of these frameworks to learn how to tune the logging level.

How does my spring web app capture errors that I didn't catch and log? Is this a result of apache commons?

I'm confused as to how the errors are logged without me implicitly catching them and logging out the error. All that I've done is put a log4j.xml file in my project defining appenders and now the logs catch and log everything from the frameworks.
If I say, try to query in Hibernate and the query fails, or I try to open a file that doesn't exist, or I get a null pointer exception, if the log4j.xml file defines a log file, and the error level is set correctly, then the error will be captured there?
How does my spring web app capture errors that I didn't catch and log? Is this a result of apache commons logging?
Or is this some magic that log4j knows how to deal with - catch stream to the console etc?
Any info appreciated.
From spring official documentation:
The nice thing about commons-logging is that you don't need anything else to make your application work. It has a runtime discovery algorithm that looks for other logging frameworks in well known places on the classpath and uses one that it thinks is appropriate (or you can tell it which one if you need to). If nothing else is available you get pretty nice looking logs just from the JDK (java.util.logging or JUL for short). You should find that your Spring application works and logs happily to the console out of the box in most situations, and that's important.
To make Log4j work with the default JCL dependency (commons-logging)
all you need to do is put Log4j on the classpath, and provide it with
a configuration file (log4j.properties or log4j.xml in the root of the
classpath).
Take a look for a complete explanation: http://static.springsource.org/spring/docs/3.0.x/reference/overview.html#d0e743

Is log4j thread-safe?

I have a following question. We use log4j in our two projects, that are hosted on the same GlassFish server. Each project has inside log4j.properties file, that points to the files, that are based in different catalogs (let's name them Project1 and Project2).
Now, for some unclear reasons sometimes the info messages of the first project are written to Project2 log files, and the reverse is also true. I checked the log4j.properties files for both of the projects, there is nothing pointing in them to the log of the other project.
The suspicion is that log4j is not actually thread-safe, therefore if two users are working in two systems in the same time, the messages of the loggers can get mixed. Is this suspicion correct?
Yes, log4j is thread safe:
Yes, log4j is thread-safe. Log4j components are designed to be used in
heavily multithreaded systems.
Ref.
What you are describing sounds more like a config mistake, rather than a cross process/threading issue.
Yes, log4j is thread safe. The reason is the method AppenderSkeleton.doAppend() is synchronized. But be carefull configuring programmatically!
For example you can't use the same instance of TTCCLayout in different appenders(read javadoc)! Take a look at PatternLayout method format(). It changes instance field(StringBuffer sbuf), so if you use same PatternLayout instance in different appenders you are to face race conditions. EnhancedPatternLayout is better, cause they modified format method.

Resources