Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Virgo » Can't make per application log file work
Can't make per application log file work [message #1767688] Sun, 09 July 2017 23:45 Go to next message
dustContributor dustContributor is currently offline dustContributor dustContributorFriend
Messages: 2
Registered: July 2017
Junior Member
Hi!

I'm trying to use Virgo as a sort of tiny app server to run local periodic Java services, ie, no web sites, no Spring, just plain Java and OSGi stuff.

I've managed to make a bundle and configure it through the configuration manager, which becomes really handy with the hot-reloading of .properties in the pickup folder.

I'm stuck in trying to get per-application log files though. Have in mind that I have no idea about how standard logging is usually done with slf4j, logback, or anything.

From what I've read, to get a per app log file I need a .par. I don't see a way to generate a .par directly from Eclipse, so I just added the expected .par attributes in the MANIFEST.MF (Application name, version, symbolic name and description), and change the exported plugin's file extension from .jar to .par.

That way I get Virgo to create the app folder, and a log file with a few things, but none of the things I'm logging in my bundle.

I've tried to use System.out and System.err, neither gets to the application's log file. And I tried with LoggerFactory.getLogger( clazz ), but that logger isn't writing to the application's log file either.

I have no idea what else I must do to get the bundle to write into the per-application log file. I just wanted some tracing information, ie "mainTask: Starting", "mainTask: Execution failed, retrying", "mainTask: Success", and so on.

If it's relevant, my application has an Activator, that uses a ScheduledThreadPoolExecutor to schedule a periodic task. Both the Activator and the periodic task will be logging some trace information. The activator initializes the scheduler, and registers itself as a ManagedService, when the configuration update method is called, it uses that data to schedule the periodic task. When the bundle is stopped, the activator cancels the pending task and shuts down the scheduler. That's all it does.

Any pointers?
Re: Can't make per application log file work [message #1768004 is a reply to message #1767688] Wed, 12 July 2017 18:54 Go to previous messageGo to next message
daniel marthaler is currently offline daniel marthalerFriend
Messages: 77
Registered: April 2012
Location: Zürich
Member
Please see the relevant section in the Programmer Guide [1] and User Guide [2] for the details about logging facilities provided by Virgo.
In the User Guide you will find the following info:
Quote:

It provides application trace files that contain application-generated output. This includes output generated using popular logging and tracing APIs including the OSGi LogService, as well as output generated by calls to System.out and System.err. These files are intended for use by application developers and system administrators. An application is defined as a scope so a single bundle will not get its own log file unless it is a Web application Bundle or is included in a scoped plan or a par file.


I suggest you use Slf4j Logger to issue log statements in your code. The bundle you've created together with the properties file can be put into the usr repo (VIRGO_HOME/repository/usr). Then you could use a scoped plan file to deploy your application by placing only the plan file in the pickup folder. Info on how to create a plan file can be found here [3]. Doing this and making sure the plan is a scoped plan you will get an per application log file.

[1] https://www.eclipse.org/virgo/documentation/virgo-documentation-3.7.1.RELEASE/docs/virgo-programmer-guide/html5/virgo-programmer-guide.html#_application_trace
[2] https://www.eclipse.org/virgo/documentation/virgo-documentation-3.7.1.RELEASE/docs/virgo-user-guide/html5/virgo-user-guide.html#__trace_logging
[3] https://www.eclipse.org/virgo/documentation/virgo-documentation-3.7.1.RELEASE/docs/virgo-programmer-guide/html5/virgo-programmer-guide.html#_creating_plans
Re: Can't make per application log file work [message #1768783 is a reply to message #1767688] Sun, 23 July 2017 20:08 Go to previous messageGo to next message
dustContributor dustContributor is currently offline dustContributor dustContributorFriend
Messages: 2
Registered: July 2017
Junior Member
Oh I see.

Does that means that when it says "scoped plan or a par file" it isnt actually true? I mean, as I described, par file alone isn't enough to pipe my own logs to their own file.

I read that bit, that's why I tried with the par file.

When you say you suggest me to use SLF4J logger you mean to use " LoggerFactory.getLogger( clazz )" instead of just System.out ? As I mentioned, I don't really have experience with the various logging facilities.
Re: Can't make per application log file work [message #1768855 is a reply to message #1768783] Mon, 24 July 2017 11:24 Go to previous message
daniel marthaler is currently offline daniel marthalerFriend
Messages: 77
Registered: April 2012
Location: Zürich
Member
You may have not built a correct .par file. As I wrote in my first answer, the easiest way to get it working is by creating a .plan file which has the scope attribute set to true.
About the logging, yes use the Slf4j logger when possible. Consult the official documentation [1] on how to use it.

[1] https://www.slf4j.org/docs.html
Previous Topic:Virgo 3.7.0.M01 - multiple bundles into same plan generates a dump error
Next Topic:Virgo 3.7.2.RELEASE is available
Goto Forum:
  


Current Time: Thu Apr 25 20:05:39 GMT 2024

Powered by FUDForum. Page generated in 0.02969 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top