I'm trying to run tinylog inside glassfish 3.1.2.2. First I copied tinylog.jar into /glassfish3/glassfish/domains/domain1/lib
. Second I created tinylog.properties
inside domain1/config
. tinylog.properties
is like this:
tinylog.format={date}-[{class}:{method}:{line}]-{level}-{message}
tinylog.writer=rollingfile
tinylog.writer.filename=log.txt
tinylog.writer.backups=5
tinylog.writer.label=count
tinylog.writer.policies=size: 10KB
My application is a simple web service like this:
@WebService
public class Calculator {
@WebMethod
public int sum(int a, int b) {
Logger.info("new request. a = {0}, b = {1}", a, b);
return a + b;
}
}
Now when I ran web service it works and returns results. But logs are inside logs/server.log
like this:
[#|2012-09-08T14:15:03.801+0430|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=175;_ThreadName=Thread-2;|2012-09-08 14:15:03 [http-thread-pool-8080(1)] com.argengco.tiny.Calculator.sum()
INFO: new request. a = 43, b = 7
|#]
since tinylog writes logs to stdout by default and glassfish redirects stdout to javax.enterprise.system.std.com.sun.enterprise.server.logging
logger, it seems tinylog did not find tinylog.properties
. I don't see any permission error in server.log
which tells it can not open tinylog.properties
. can anyone help?
If /glassfish3/glassfish/domains/domain1 is the root of your source build tree (i.e. it contains com/blah/blah) then you need to either:
1) Put the tinylog.properties file in that directory
or
2) Call PropertiesLoader.loadFromFile("config/tinylog.properties");
I came across your question after trying to find the answer myself. After rebuilding the source code with some debug messaging (minor irony!) I worked out the answer.
In my case I had a src/com/blah/blah directory structure. In this case the tinylog.properties file needs to go in the src/ directory.