I wrote a log parser that constantly reads the log file gets specific lines from the log and writes them into database. Logs are generated via LOG4J. Logs are being rotated when they reach specific size. My problem is that my log parser process is not allowing log4j to rotate the logs.
Can you please advice on this.
Regards.
A cleaner solution would be to use org.apache.log4j.jdbc.JDBCAppender for the log statements that you want in the database, and have log4j insert them directly.
Related
I am adding a new appender and calling org.apache.log4j.PropertyConfigurator.configure(). However, this seems to override the default databricks logging and I can no longer see the logs as normal from driver-logs or executor logs view.
I think databricks probably use some FileAppender. How could I add new appender while keeping existing databricks ones please?
Don't call org.apache.log4j.PropertyConfigurator.configure yourself to extend the built-in logging configuration. Rather, do it by defining an arbitrarily-named log4j.properties file in the /databricks/spark/conf/ directory. (reference) Also, you might need to use an init-script to ensure that the file is added to all nodes in the cluster.
Spring Integration defines both <int:logging-channel-adapter/> and <int:message-history/> elements for logging. What is the default directory/folder where these files are placed? Also, is this location configurable?
Thanks
<int:message-history/> isn't for logging. It just stores the 'journey' of the message to its headers. Right, it is done in some convenient form, which is useful to be logged.
<int:logging-channel-adapter/> it doesn't store anything to the disk. This component just does log.debug(), log.info() etc.. Where logs are stored it's up to logging system configuration.
How does your logging system works is out of Spring Integration scope: you can simply store logs to file, or to the DB, or send them to JMS, or AMQP, or just show in console. So, investigate, please, how you can fix your 'issue' with you logging system: log4j, commons-logging, slf4j etc.
I am able to find the GET parameters that are made as part of a request but I am not able to retrieve the POST parameters for a request. Can you guys tell me what should be my search parameters for the same?
Does IIS actually log this?
Thanks in advance.
IIS does not log POST parameters. POST is commonly used for large data sets and file uploads which would take up a ton of space on your disk and could cause your server to run out of space easily.
You can setup some manual logging with something like log4net and log POST parameters. File growth will still be a problem but log4net can be configured to limit growth and roll-over at a certain size. You can then index your log4net logs using splunk
Please help me with this query in using log4net.
I am using log4net in mhy we application. I am facing issues in configuring log4net to log errors at user level.
That is, If user X logs in, I like to create file name X and all error for user X should be written in X.log. Siilarly if Y user logs in the log file should be in name of Y.log and the most important point to note is, they could log in concurrently.
I tried the luck by creating log files whose name would be framed dynamically as soon as the user logs in. But issue here, if they are not using the application at the same time, the log files are creeated with correct name and writing as expected, but if both users have active sessions, log file is created only for user who FIRST logged in and error of second user has been recorded in log file that is created for FIRST user.
Please help me in this.
There has to be a better solution from this one, but you can change log4net configuration from code and even decide which config file to load - so you can do it in code, which is not as nice as editing an XML file.
so what you need to do, which is highly not recommended, is to create log4net configuration each time you call the logger static class, and do what needed based on the calling user.
again.. it doesn't feel right !
(and it will probably perform poorly).
another BETTER solution is to log everything to database (log4net supports it), with a user column, and then produce the logs from db....
We have multiple log files like database log, weblog, quartzlog in our application.
Any log from files under package /app/database will go to database log.
Any log from files under package /app/offline will go to quartzlog log.
What we need now is - want to direct the log staments from one of the java file under /app/database to be outputted to quartzlog instead of database log.
How can we select a particular log file in java file?
You need to define the appropriate appender that logs in the desired file. Read this short introduction to see how you can do it.
Then in the configuration file, you can instruct all messages from a specific package to go in the selected appender:
log4j.logger.my.package = DEBUG, myFileAppender
EDIT:
I believe that in log4j only package resolution is possible - you can't use an appender per file or method. You could try to work around this by adding an extra layer on top of log4j or implementing your own appender.
For example, instead of log.debug use:
my.loggerproxy.log.debug(message);
If you only need to do it from a single method, then the above will be enough. Just instruct the logger proxy package to be logged in a different file.