I'm trying to log errors through email using Log4j2.
For that purpose Log4j2 defines the SMTPAppender, and an example configuration is provided to use in the XML config file, which is like:
<appenders>
<SMTP name="Mail" suppressExceptions="false" subject="Error Log" to="errors#logging.apache.org"
from="test#logging.apache.org" smtpHost="localhost" smtpPort="25" bufferSize="50">
</SMTP>
</appenders>
So everything should be fine. But when i start the application and force an error to log i receive this message:
ERROR Error processing element SMTP: CLASS_NOT_FOUND
Ok, now what to do? the documentation gives a hint, plugins, and packages should be used, both of which have little documentation, and no examples.
I got another hint in: ClassNotFoundException javax.mail.internet.AddressException when running hibernate3:hbm2ddl but this is log4j2 and not log4j.
Any help is, of course, greatly appreciated.
The answer was easy.
After reading this https://blogs.apache.org/logging/entry/apache_log4j_2_0_beta4
I downloaded the beta4 (i had the beta3) and now i have other problems, but the appender works.
Related
I have a non-Spring appliation. However, we are pulling in spring-security-config and spring-security-web. We use Log4j and have a log4j.properties file.
We want to log all the output from 'org.springframework' with the 'trace' log level.
We do not have an application.properties file, but can create one if we need one.
So, when I run my non-Spring app, all my code logs properyly, but I am not seeing anything from org.springframework in my logs.
Since Spring Security pulls in Spring Core, we created an application.properties on the classpath. We then setup a logging.file property to our log file. Then we setup some other logging property files to see if that would help. We also set debug=true as well.
So, I'll keep trying ....
Thanks in advance!
So, I found the problem. The logs were going to another log file in a different directory. I believe this is because it was a container log and not an application log.
Hope this helps someone else out.
I've been tasked to setup a logging system that uses Apache Pulsar as the appender to Log4j2. I'm really lost on how to set this up and there doesn't seem to be any documentation/examples to go by. Does anyone have an idea how to go about this?
I found an example in the Pular Appender's test project. I would suggest you look at that as it shows 5 different configurations. However, I would not recommend the SerializedLayout as it can lead to security vulnerabilities.
As we know by default logging in Grails 3.0 is handled by the Logback logging framework and can be configured with the grails-app/conf/logback.groovy file. The good part of this was that the configuration inside this file was applicable for the Logback and Log4j implementations (tested successfully in Grails 3.1.2). After we migrated to use Grails 3.2.8 from Grails 3.1.2 (as I said before), it seems that the configuration inside the logback.groovy file is not used by the Log4j and it should be configured in other way - at runtime.
I made a deep research in this to ensure that this is really the way it is configured now and it seems that if I am using the default Log4j logging:
org.apache.log4j.Logger.getLogger("name").info("TEST");
is not working at all. To make the information populated into the output log file, I should use the default SLF4J API:
org.slf4j.LoggerFactory.getLogger("name").info("TEST");
The problem here is because that we have a lot of places in the code where the logging is implemented using Log4j approach and now - nothing is written in the log file.
So I have two questions here. The first one - is this the exact way how Grails implemented this behavior (as nothing is mentioned in the official documentation - Grails 3.2.8 Documentation). The second one - is the XML or RUNTIME configurations are the best way to configure the Log4j, so use it as before. If yes - the bad thing here is that we should maintain two same configurations at a time. Is there any other way to configure the Log4j to use the same configuration as the Grails Logger.
P.S. There is no need to publish any code, as all are just default configurations.
Thanks a lot!
appender('STDOUT', ConsoleAppender) {
encoder(PatternLayoutEncoder) {
charset = Charset.forName('UTF-8')
}
}
root(ERROR, ['STDOUT'])
logger("<package_name>", DEBUG)
List artifacts = ["conf", "controllers", "domain", "init"]
artifacts.each { artifact ->
logger("grails.app.${artifact}.<package_name>", DEBUG)
}
After writing this, you can add logger for debugging in any artifacts mentioned above like:
log.debug "Any Message"
For more setting you can read here: https://logback.qos.ch/manual/groovy.html
I am getting below error when I try to deploy to the azure. I am doing basic hello world app. Can someone please give some insights. I have attached the logs below.
I am using :: Version 1.1.0-beta2
The silos start properly as per the log files but it cant initialize the Client in azure. I am using the below config file in the Client.
<?xml version="1.0" encoding="utf-8" ?>
<!--
This is a sample client configuration file for use by an Azure web role acting as an Orleans client.
The comments illustrate common customizations.
Elements and attributes with no comments should not usually need to be modified.
For a detailed reference, see "Orleans Configuration Reference.html".
-->
<ClientConfiguration xmlns="urn:orleans">
<!--
To turn tracing off, set DefaultTraceLevel="Off" and have no overrides. To see a minimum of messages, set DefaultTraceLevel="Error".
For the trace log file name, {0} is the silo name and {1} is the current time.
Setting WriteTraces to true will cause detailed performance information to be collected and logged about the individual steps in the
message lifecycle. This may be useful debugging performance issues.
-->
<Tracing DefaultTraceLevel="Off" TraceToConsole="false" TraceToFile="{0}-{1}.log" WriteTraces="false">
<!--
To get more detailed application logging, you can change the TraceLevel attribute value to "Verbose" or "Verbose2".
Depending on the log levels you have used in your code, this will cause additional messages to be written to the log.
-->
<TraceLevelOverride LogPrefix="Application" TraceLevel="Info" />
</Tracing>
</ClientConfiguration>
PS::
I figured it out after enabling the fusion logs. I could see 1 dll was not loaded properly. The issue is fixed.
You should be using AzureClient. It handles all configuration automatically.
Please refer to https://github.com/dotnet/orleans/tree/master/Samples/AzureWebSample and follow the same setup as there. The best way is to close that AzureWebSample and add your own grains and logic.
What version of Orleans are you using? If you included http://www.nuget.org/packages/Microsoft.Orleans.Templates.Interfaces/ in the project, the invoker class should have been generated at compile time. Try cleaning up Properties\orleans.codegen.cs files and rebuilding the project.
I'm getting this error message in the index.jsp file
Can not find the tag library descriptor for "http://struts.apache.org/tags-logic"
How do I rectify it?
Refer this Hello World Application tutorial link, you can compare your code with this sample codes and solve your issue.
Jar files which all are required are also available there in that link ( Except MySQL connector).