0

I am unable to determine how to get a logfile. Other changes to logging - including setting DEBUG level on console - are working.

Here is the update to the resources/application.conf:

akka {
  loglevel = DEBUG
  event-handlers = ["akka.event.slf4j.Slf4jEventHandler"]
}

Here is the resources/logback.xml:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>

    <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
        <target>System.out</target>
        <encoder>
            <pattern>%date{MM/dd HH:mm:ss.SSS} %-5level[%.15thread] %logger{1} - %msg%n</pattern>
        </encoder>
    </appender>

  <appender name="FILE" class="ch.qos.logback.core.FileAppender">
        <file>akka.log</file>
        <append>true</append>
        <encoder>
            <pattern>%date{MM/dd HH:mm:ss} %-5level[%thread] %logger{1} - %msg%n</pattern>
        </encoder>
    </appender> 

    <root level="DEBUG">
        <appender-ref ref="CONSOLE"/>
        <appender-ref ref="FILE"/>
    </root>

</configuration>

The logger is being accessed via

class MyWebsocketServer extends Actor with ActorLogging {
..
log.info("I see this on the Console but no files to be found..")

UPDATE

Following is the output at beginning of the process. Notice that only "default" loggers are mentioned.

[info] Running com.huawei.swlab.sparkpoc.spray.SimpleServer
[DEBUG] [05/21/2014 11:46:23.039] [run-main] [EventStream(akka://default)] logger log1-Logging$DefaultLogger started
[DEBUG] [05/21/2014 11:46:23.041] [run-main] [EventStream(akka://default)] Default Loggers started

It is becoming clear that the logback.xml is not being picked up. I ran the following from the git clone'd root dir:

sbt run

This is apparently not working in terms of the akka system is not looking for the src/main/resources. I will instead make an explicit addition to the classpath to see if that resolves it. Should not be necessary, but i'm fishing at this point.

Another update The sbt classpath was modified to include the src/main/resources - just in case. This did not have any effect.

WestCoastProjects
  • 58,982
  • 91
  • 316
  • 560
  • What do you mean exactly with "get a logfile" and what isn't working? spray's website successfully uses a very similar configuration: https://github.com/spray/spray/blob/master/site/src/main/resources/logback.production.xml – jrudolph May 21 '14 at 07:48
  • No log file is generated anywhere under the project or in obvious places to look such as /tmp (/temp) the user's home directory , etc. – WestCoastProjects May 21 '14 at 09:06
  • Are you using ActorLogging or a logger factory? Can you show how you are using the logger? – Gangstead May 21 '14 at 15:47
  • @Gangstead OP updated about usage. – WestCoastProjects May 21 '14 at 15:50

1 Answers1

2

Put a full path and file name like <file>/Users/javadba/akka.log</file>

Edit: I found where the relative paths start from. I'm running on a Tomcat server started by STS (Eclipse distro) on a Mac. When I used your logback.xml file as is the file is put inside the app contents:

/path/to/STS/STS.app/Contents/MacOS/

Inside the package won't be searched by the file system and you have to right click "Show Package Contents" to browse into it. I think the equivalent location on Windows would be the AppData directory, which is also hidden and won't show up in file system searches.

If you are on a Mac and your sbt was installed with Brew then check /usr/local/bin

Gangstead
  • 4,152
  • 22
  • 35
  • So .. given the configuration displayed above in the OP (default locatoin), where would the log file be? – WestCoastProjects May 21 '14 at 14:31
  • I'm not sure, maybe the directory you started the application from like in Java: http://stackoverflow.com/questions/5154529/in-java-what-is-the-default-location-for-newly-created-files – Gangstead May 21 '14 at 14:54
  • From the OP: i already checked that directory (numerous times). – WestCoastProjects May 21 '14 at 14:54
  • If you are starting from the command line it wouldn't necessarily be the project directory. Did the full path not work? – Gangstead May 21 '14 at 15:47
  • I just tried your logback configuration and the only thing I have to change to make it work is to put a full path for the file name. I'm on a mac and running my application through tomcat in Eclipse. – Gangstead May 21 '14 at 18:37
  • Hi, I have not been in a position to re-attempt. Would you please tell me: have you seen any log file when the default path - which is a "relative" path is used? I will in any case likely accept the answer in a day or so when I get a chance to retry with the log configuration updated with an FQ path. – WestCoastProjects May 21 '14 at 18:41
  • I just went ahead and re-tried. No dice. I have updated the OP with more details: pls take a look and see what is different to the way you are launching/running the server. – WestCoastProjects May 21 '14 at 18:47
  • I am going to go ahead and upvote this answer since it is 'helpful' in the sense of some impetus on areas to consider. But it does not actually answer the question (still have same issue). – WestCoastProjects May 23 '14 at 19:27