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.
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.
How can I redirect all the JSF error log messages to a log file? Currently it is being written to a SystemOut.log file.
I tried to change the System.out to a custom PrintStream which will write to a log file and it is logging the system out statements to the log file. But the JSF error messages are still being written to the SystemOut.log file.
Mojarra uses the java.util.logging logger. So all you need to do is to supply or change the logging.properties file in the runtime classpath. You can if necessary override/specify the properties file location using the VM argument -Djava.util.logging.config.file.
Another way is to configure it at the servletcontainer level. It's unclear which one you're using, but the exact filename SystemOut.log is typical for among others WebSphere. You can instead also just configure tracing/logging in its admin console.
I am using log4net in a web app, and log all page errors to a SQL server. I was wondering if there was any way to retrieve the entry ID generated by it. I'm going off of the documentation found here
http://logging.apache.org/log4net/release/config-examples.html
I want to use this ID as a reference number I can show to a customer so that they may contact customer support to lookup in the system and not have to go through a log file.
Apart from writing your own appender as floyddotnet suggested you could consider:
Use a GUID. You can easily generate it in your application and will serve most of your purposes. Drawback: It may be inconvenient for the customers if they try to tell your support stuff about it on the phone. If you have only email support than this is maybe not an issue.
Consider creating an incident number outside of the logging framework. A quick call to a stored procedure that returns an ID that you save in a nullable field in your log table.
A combination of the above: Use a Guid and after logging you call a stored procedure that creates an incident and returns the ID.
Writing an appender that returns the ID creates a dependency between your application and appenders that you normally do not have: Log4net was designed with a clear separation between logging and writing the log messages somewhere. The appender that you need would affect that separation.
Since the ID is generated by the database and not by log4net, I don't believe this information is available to you.
What I've done in using log4net for such conditions is to include a datetime stamp in the message that goes down to the millisecond and present that to the user as a reference number. You can do then do a simple SQL query to get to the message in the log table.
I'm not sure its posible but you can write your own Appender for log4net end store this information in the log4net-context.
Howto writing an appender for log4net:
http://www.alteridem.net/2008/01/10/writing-an-appender-for-log4net/
Context-Description:
http://logging.apache.org/log4net/release/manual/contexts.html
I am using Log4Net API in my application to log any important event or information as well as logging my exceptions in database.
There might be an exception while using Log4Net API; if it fails to perform logging into database then how will this exception be stored? Where will all other logging and exception logging be stored in case the Log4Net API fails to perform logging?
Log4net will fail silently so that the primary function of the application is not disturbed. If you have an event that you absolutely need to have in the database, the you should make it part of your business logic i.e. write it yourself to the database.
If you insist using log4net for this, then you could write an appender that has some fail over logic that makes sure that all events get logged to the database (eventually). However this does not seem to be a good idea...
As for normal logging: In order to ensure that I have logs I usually use a rolling file appender in addition to other appenders. This way I can be quite sure that in the worst case I have the log available in a file.
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.