Log4j - log file per package - log4j

I am using log4j and I cant figure out, how to create log file for specific classes (in my case for security messages).
I want to have one global log, where I will log everything (INFO), and some package specific log files for debugging, testing and security of some parts of my app.
For instance I want to log only events from LoggerListener (Spring security) to file security.log, and only messages from my apps package cz.flexibla2 *to flexibla2.log* etc.
Thanks for your help.

Related

wildfly 20 doesn't log with log4j. Which factors Can be involved for that?

I have two environment development(local) and other QA environment, In the last is a cluster with two nodes.
The problem came with the deploy in QA environment I can't see the log in the server, but locally print console logging without problem.
I'm sure that module structure is the same in both environments, and my configure is in the classpath with xml file.
Which aspect can influence in this difference?
Local print logging console server and QA enviroment dont do it.
I was able to solve this, I checked the server in the development environment, it's a domain configuration and for this reason it did not show the application log in the user wizard, due to application conditions only the applications write to the .log file, at start I was not allowed to check this domain log directory, but after I check this by command line my app log file is right there
I'll hope to help someone else

Apache Tomcat security: User management & log file management

I'm trying to monitor Tomcat log files from a security perspective.
My questions are related to two main areas:
1) User Management
1.a) Does the Tomcat GUI provide any option to create and delete users, or does this have to be done directly via the tomcat-users.xml file?
1.b) Does Tomcat create any log entry when users are being created / deleted?
2) How are log files being handled?
2.a) Is there any option provided by the GUI to modify / delete Tomcat log files?
2.b) Are modifications in log files being logged in some log file only accessible by root?
The reason I'm asking is that I would like to look for relevant security events in Tomcat logs to establish some kind of monitoring on this. However, the only thing I could find was "Access Logging" for Tomcat, which unfortunately does not answer my questions.
Very short answers:
1.a.: the tomcat gui doesnt provide options to create, modify or delete users
1.b.: because of the absence of the corresponding functionality, not any logs are created
2.a.: the tomcat gui doesnt provide opstions to modify or delete log files
2.b.: because of the absence of the correspondig functionality, not any logs are created
the tomcat-users.xml is a very slim and lightweight out of the box solution
usually developers make use of an identity-management like ldap or they develop and/or implement their own user-administration

Log4j sorting logs

I am running one jar on unix machine and takes output of it on windows machine program using JSCH. So, i am creating log file on unix machine this will be detailed log file of jar present on unix.So, here i want to print some restricted output on unix console and take it on my windows application after executing the JAR file and all other info will go into detailed log file.So how i will print restricted output on console using log4j? what i need to do to achieve this? can anybody gives example of this?
You have to configure 2 different "appenders": a ConsoleAppender and a FileAppender, then you can direct output to one of them or both. To select which appender will receive a log item you can discriminate on logging priority (for example console could receive only ERROR and FATAL items, the log file could receive everything) and/or the class or package producing that log item. The log4j intro documentation page explains how to make this configuration.

Unable to start Message Engine in Websphere

I am facing a problem while starting the websphere message engine for one of the application deployed on websphere. This application is getting deployed automatically as a part of the installation of Websphere Lombardi 7.2 express edition. It's using websphere 7 internally to deploy it. When I try to start the message engine from the administrative console of websphere I am getting following error:
The messaging engine ProcessCenter01.twperfsvr-twperfsvr_bus cannot be started as there is no runtime initialized for it yet, retry the operation once it has initialized. For the runtime to successfully initialize the hosting server must be started, have its 'SIB service' already enabled, and dynamic configuration reload enabled. If this is a newly configured messaging engine and it is the first messaging engine to be hosted on this server, then it is most likely the 'SIB service' was not previously enabled and thus the server will need to be restarted. The messaging engine runtime might not be initializing because of an error while trying to start, examine the SystemOut.log of the hosting server to check for error messages indicating the problem.
After restarting the server, the same error shows. Can anyone help me to to find what gets loaded as a part of "initialization of runtime"? Are there any config files etc. that I need to check to solve this issue? I am suspecting some missing configuration causing error to load the runtime for this particular application.
I too faced this issue today had to delete all the files under the message store
check the directory-file path mentioned in
Application servers > server1 > Messaging engines > XXX.server1-primaryBus > File store
Just Enable the SIB Services For the particular Server.
Example:Server-->Application Server-->click on Server Name-->right hand side we can see SIB services-->Check box the Enable services.
This will solve your problem
Recently I have faced the same issue when I rebuilt the jvms in UAT envt. After searching on web I found that because of the old messages saved in the message store(flat files in my envt) the messaging engines was not getting initiated. After deleting the old messaging store and restarting the servers it got initialized.
I have struggled with this problem too.
In our situation the problem was that the file message store location was used that was already created for a different (or old) message-engine.
If you add a busmember to the service-bus and use a file store implementation, then you need to supply the path for the store and log folder. Make sure these locations don't exist yet, other wise you will run in the problem above. The message-engine for this member will use these folders.
If you have a script for creating the message-bus infrastructure, make sure that when you delete the bus or remove message-engines, that you remove the file store/log folders for these, before you re-run your script.
Another possibility is that you are using a external database as a data store, and the user that is used for the connection is not allowed to create a database. You might find a ffdc entry like this:
DB2 SQL Error: SQLCODE=-552, SQLSTATE=42502, SQLERRMC=DB2ADMIN;CREATE
SCHEMA, DRIVER=3.61.65
Then you have to go to your database administration tool and give DB2ADMIN the proper privileges. Then restart the server or cluster.
Finally this issue is been resolved. I did not create the schema in SQL Server with same name as that of the username I gave to connect SQL Server during the installation of WLE 7.2
Please find details about this at below link:
http://www.ibm.com/developerworks/forums/message.jspa?messageID=14795282

Mule Logs not showing

I'm trying to launch a Mule application I have written, but I cant seem to get the logs to show up when I run it from the console. When I look at the log file, I see the Mule loading process (assuming I am using the app not the service mode) but then the log goes blank. Note that the log is visible when I'm using Mule Eclipse IDE.
Sounds like your app logging configuration overrides the global one, but is also not doing what you expect. Add -M-Dlog4j.debug switch to the Mule command line to see where rogue log4j config file might be coming from.
To properly log Mule messages into a log file, you should have a category definition in your log4j.properties and refer to that in your Mule flow as:
<logger level="INFO" category="your_custom_category" message="#[payload]"/>
Try to restart the entire machine. It sounds like an Eclipse problem not a problem with your program.
May be you have not properly placed the properties file and jar file.
Place
"log4j.properties" in "WEB-INF/classes"
and copy
log4jx.y.z.jar to "WEB-INF/lib".

Resources