I am working with logback for the first time with Jetty. I have everything working but I do have one annoying thing that I can't figure out. Once Jetty starts, I begin to get a log file filled with these:
2013-03-02 11:19:23.933:DBUG:oeju.Scanner:scanned [C:\Code\jetty-8\contexts]: {}
2013-03-02 11:19:24.646:DBUG:oeju.Scanner:scanned [C:\Users\willie\AppData\Local\Temp\context5868271910991031759deploy]: {}
2013-03-02 11:19:24.938:DBUG:oeju.Scanner:scanned [C:\Code\jetty-8\webapps]: {}
2013-03-02 11:19:24.943:DBUG:oeju.Scanner:scanned [C:\Code\jetty-8\contexts]: {}
2013-03-02 11:19:25.655:DBUG:oeju.Scanner:scanned [C:\Users\willie\AppData\Local\Temp\context5868271910991031759deploy]: {}
2013-03-02 11:19:25.948:DBUG:oeju.Scanner:scanned [C:\Code\jetty-8\webapps]: {}
2013-03-02 11:19:25.952:DBUG:oeju.Scanner:scanned [C:\Code\jetty-8\contexts]: {}
2013-03-02 11:19:26.665:DBUG:oeju.Scanner:scanned [C:\Users\willie\AppData\Local\Temp\context5868271910991031759deploy]: {}
2013-03-02 11:19:26.958:DBUG:oeju.Scanner:scanned [C:\Code\jetty-8\webapps]: {}
2013-03-02 11:19:26.963:DBUG:oeju.Scanner:scanned [C:\Code\jetty-8\contexts]: {}
2013-03-02 11:19:27.675:DBUG:oeju.Scanner:scanned [C:\Users\willie\AppData\Local\Temp\context5868271910991031759deploy]: {}
2013-03-02 11:19:27.968:DBUG:oeju.Scanner:scanned [C:\Code\jetty-8\webapps]: {}
2013-03-02 11:19:27.973:DBUG:oeju.Scanner:scanned [C:\Code\jetty-8\contexts]: {}
The syntax for the filtering in logback is a little on the cryptic side and I can't figure out how to tell logback to ignore these scan events. I have tried the obvious
<filter class="oeju.Scanner" />
but it doesn't work. Can anyone out there give me a little help with this?
The log format you are seeing is not logback
2013-03-02 11:19:26.665:DBUG:oeju.Scanner:scanned ....
that is the log format that Jetty's own internal StdErrLog produces.
So filtering it out with logback will not work (yet).
How to make logback work in Jetty
First, make sure you have the slf4j-api, and logback jars present in your server classpath.
Easiest way to accomplish this is to put them in ${jetty.home}/lib/ext/ and verify that they are present with a quick check on the command line.
$ java -jar start.jar --version
That will show you what the server classpath will have in it.
Now start jetty. The slf4j-api classes should be detected and the internal logging switches over from StdErrLog to Slf4jLog.
At this point you just have to configure logback. Usually with a ${jetty.home}/resources/logback.xml file. (See logback documentation for details)
The meaning of oeju.Scanner
As for the oeju.Scanner part, that is an abbreviated fully qualified classname that StdErrLog produces for the named logger org.eclipse.jetty.util.Scanner. See how it only uses the first letter of each package namespace segment to form the oeju?
How to filter Scanner events in logback
In your logback.xml use the following, in place of what your question had, to set the logging level to INFO for that specific class.
<logger name="org.eclipse.jetty.util.Scanner" level="info" />
Related
I would like to add some extra data to my log output depending on where it was logged. For instance I might have System A and System B, both spitting out log data, but perhaps I'm only interested in System B's log lines now so I could filter based on the tag.
In a previous system I had a log function that looked like LOG(level, tag, message) but I could also see a solution that could involve instantiating a logger with a tag for each system that would pipe to a default logger that catches all messages. So spdlog::tagged_logger systemALogger("System A");
This is almost the answer since loggers can have names, I could use the names as a tag, but can loggers redirect to a default logger? The default logger has several sinks that I would have to attach to the named logging solution.
So the final question would be, is there a way to add a custom tag to log messages in spdlog?
Once you have your log configured, you can clone() it and pass a custom logger name that will appear in the log output (given you have not change the formatting).
auto logger = spdlog::default_logger()->clone("my_logger");
logger->info("message from custom logger");
spdlog::info("message from default logger");
The contents of the basic-log.txt is as follows:
[2020-12-02 09:35:58.801] [my_logger] [info] message from custom logger
[2020-12-02 09:35:58.802] [info] message from default logger
I would like to ask how can I start another flow using quartz.
Starting each flow seperately (one is trigered with IMAP and second with Quartz) works ok, but I would like to have both of them in same file if possible, or at least in same project. I don't know what is good practice for this so I let you decide.
So, Flow1 starts with IMAP and do its job with mail (original) and then goes on to other subflows.
Flow2 starts with quartz and do its job (the one I would like to add)
Both flows have same variables and have similar job but don't have to be sinchronized of course.
Now, how can I achieve this?
I tried this:
<flow name="Flow1" doc:name="Flow1">
<imaps:inbound-endpoint doc:name="IMAP"
host="imap.gmail.com" port="993" responseTimeout="10000"
........
</flow>
<flow name="Flow2" doc:name="Flow2">
<quartz:outbound-endpoint jobName="FlowStarter" repeatInterval="10000" responseTimeout="10000" doc:name="Quartz">
<quartz:event-generator-job groupName="QuartzGenGroup" jobGroupName="QuartzGenGroup">
<quartz:payload>wwqda</quartz:payload>
</quartz:event-generator-job>
</quartz:outbound-endpoint>
<logger message="Quartz started at #[server.dateTime.toCalendar().toString()] #[payload]" level="INFO" doc:name="Logger"/>
</flow>
When I started this, Flow2 never gave any output.
I am using Mule Studio 3.5.0
Thank you!
In the Flow 2 use quartz:inbound-endpoint instead of quartz:outbound-endpoint. Outbound endpoint does not trigger workflow itself. It requires an additional incoming event.
Look at http://2rdscreenretargeting.blogspot.ru/2012/12/how-to-schedule-jobs-using-mule-studio.html for details on Quartz usage in Mule.
A weird case is happening in my application, some code that is in a Guice EagerSingleton is being run twice. I printed a stack trace (Below) and it shows that the public static main of jetty is being called twice. Where could I have miss-configured it?
//Stack trace (Is printing in logs twice)
at com.ea.wsop.GraphiteReporterConfig.<init>(GraphiteReporterConfig.java:50)
at com.ea.wsop.GraphiteReporterConfig$$FastClassByGuice$$22005e5b.newInstance(<generated>)
at com.google.inject.internal.cglib.reflect.$FastConstructor.newInstance(FastConstructor.java:40)
...
at org.eclipse.jetty.start.Main.invokeMain(Main.java:477)
at org.eclipse.jetty.start.Main.start(Main.java:623)
at org.eclipse.jetty.start.Main.parseCommandLine(Main.java:273)
at org.eclipse.jetty.start.Main.main(Main.java:81)
I am running Jetty 7.2.2 & Guice Version 3.0, Please comment on which other config files would be useful to post here.
or you can use either the webapp provider or the context provider but not both in this case
I am a fan of just using contexts personally, more nimble.
just remove the jetty-webapps.xml line in your start.ini
Figured it out,
I was setting up the web app in /home/j2play/j2play/jetty/contexts/app.xml and it was in the standard Jetty/webapps directory so jetty was scanning and starting it automatically too. I moved my war outside the standard location and it works fine.
I'm running an ant jetty task and i want to provide several jvmargs associated to jetty process :
-Xmx
-Dcom.sun.management.jmxremote.port
-javaagent
-...
Can't find any option available besides ANT_OPTS..
See this example:
http://ptrthomas.wordpress.com/2006/10/10/how-to-start-and-stop-jetty-from-ant/
Is anyone using Castle MonoRail and ELMAH with success?
We are using a number of Resuces to present users with friendly error messages, but if we do this the exceptions never get as far as ELMAH as the MonoRail rescue intercepts them.
Ideally we want the user to see the rescue, but for the exception to be logged in ELMAH.
Any ideas/pointers?
Cheers,
Jay.
After looking at the links Macka posted, I wrote this simple monorail exception handler:
public class ElmahExceptionHandler : AbstractExceptionHandler {
public override void Process(IRailsEngineContext context) {
ErrorSignal.FromCurrentContext().Raise(context.LastException);
}
}
Then I registered it in web.config, monorail section:
<monorail>
<extensions>
<extension type="Castle.MonoRail.Framework.Extensions.ExceptionChaining.ExceptionChainingExtension, Castle.MonoRail.Framework"/>
</extensions>
<exception>
<exceptionHandler type="MyNamespace.ElmahExceptionHandler, MyAssembly"/>
</exception>
...
</monorail>
And that's it.
After also posting on Google Groups it looks like Atif may have pointed me in the right direction.
You might want to look into error
signaling in ELMAH. It is designed for
scenarios where you want to pass an
exception through ELMAH's pipeline
even if it is being handled/swallowed.
Here are some pointers to get started
with error signaling:
http://code.google.com/p/elmah/wiki/DotNetSlackersArticle#Error_Signa...
http://code.google.com/p/elmah/wiki/DotNetSlackersArticle#Signaling_e...
-Atif