New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Capture JUL logging & Add Java HTTP Server plugin #246
Comments
Hi @albertus82, thanks for posting! Are you logging an exception at SEVERE, or only a message? By default it will only mark the trace as error when an error is logged with an exception (see logic in https://github.com/glowroot/glowroot/blob/v0.9.22/agent/plugins/logger-plugin/src/main/java/org/glowroot/agent/plugin/logger/LoggerPlugin.java#L43) Check out the logger configuration https://demo.glowroot.org/config/plugin?plugin-id=logger. I think maybe the default configuration is not the best, and maybe should change https://github.com/glowroot/glowroot/blob/v0.9.22/agent/plugins/logger-plugin/src/main/resources/META-INF/glowroot.plugin.json#L16. By the way, java.util.logging support would be a great addition. Let me know if you plan to send PR, otherwise I will plan to add at some point. Thanks, |
Hi @trask, thank you for your reply. Let's start clean: import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;
public class GlowrootJulTest {
private static final int RUNNING_TIME_SECS = 300;
private static final Logger logger = Logger.getLogger(GlowrootJulTest.class.getName());
public static void main(final String... args) throws InterruptedException {
System.out.println("Starting " + GlowrootJulTest.class.getName() + "...");
for (int i = 0; i < RUNNING_TIME_SECS; i++) {
TimeUnit.SECONDS.sleep(1);
logger.log(i % 2 == 0 ? Level.SEVERE : Level.WARNING, "log message #" + i, new IllegalStateException("exception message #" + i));
}
System.out.println("Terminating " + GlowrootJulTest.class.getName() + '.');
}
} Running this code with the javaagent that includes my additions, I see no errors logged in Glowroot, but probably I'm missing something because if I run the same code using Log4j, I still have no errors in Glowroot: import java.util.concurrent.TimeUnit;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
public class GlowrootLog4jTest {
private static final int RUNNING_TIME_SECS = 300;
private static final Logger logger = Logger.getLogger(GlowrootLog4jTest.class.getName());
public static void main(final String... args) throws InterruptedException {
System.out.println("Starting " + GlowrootLog4jTest.class.getName() + "...");
for (int i = 0; i < RUNNING_TIME_SECS; i++) {
TimeUnit.SECONDS.sleep(1);
logger.log(i % 2 == 0 ? Level.ERROR : Level.WARN, "log message #" + i, new IllegalStateException("exception message #" + i));
}
System.out.println("Terminating " + GlowrootLog4jTest.class.getName() + '.');
}
}
log4j.rootLogger=INFO, stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n I'm sorry I'm not able to detect what's wrong. Anyway I'll be glad to make a pull request when this thing will work properly, of course. Thank you again. |
Ah, I see, you don't have any transactions defined. Try this:
and import this instrumentation through the UI (under Configuration > Instrumentation):
This will define a transaction for each call to sleepAndLog(int), and you will hopefully start seeing the errors in Glowroot. |
Thank you @trask, it works! I'm now refining the work. Can I assume that |
Great. Yes, good point, you can assume |
@trask I'm experiencing troubles running the test, maybe a classloader issue? The advice doesn't run, but it works properly outside the test environment. Any ideas? TY
|
Hi @trask, solved: the tests run fine but, like I'm going to open a PR containing this improvement as well as a new plugin named Java HTTP Server Plugin that I wrote to support the Java HTTP Server bundled with JRE since version 6. Tests are included. Thank you a lot for your great work. |
Closed by #248 |
Hi, |
Hi @godhanairi, have you followed instructions at https://github.com/glowroot/glowroot/wiki/Agent-Installation? Can you provide more details about what you've tried and where you are stuck? |
Dear Trask,
I added this aspect to the Logger Plugin in order to catch
java.util.logging
log records; I referenced it in glowroot.plugin.json but I don't see any Error in Glowroot's Errors tab even if I log at SEVERE level. Can you tell me if I'm missing something? I'm monitoring a simple Java client application (jar), not a web app. Thank you a lot.Alberto
The text was updated successfully, but these errors were encountered: