I tried to reproduce your problem, and I think the issue is in your logback 
config.

I think the "sift" appender is misconfigured somehow. If I replace that 
appender with a vanilla "file" appender, then things work fine.

If you want to see the code I used, I have pushed it to my GitHub:
https://github.com/RichardBradley/akka/commits/logback-write-to-file
https://github.com/RichardBradley/akka/commit/00fa0f2556a7b96bdc59b2076801a75ae9a8bcf7

You should be able to run:

$ git clone [email protected]:RichardBradley/akka.git
...
$ cd akka
$ git checkout logback-write-to-file
...
$ cd akka-samples/akka-sample-main-java
$ sbt run
[info] Loading project definition from 
akka\akka-samples\akka-sample-main-java\project
[info] Set current project to akka-sample-main-java (in build 
file:akka/akka-samples/akka-sample-main-java/)
[info] Compiling 1 Java source to 
akka\akka-samples\akka-sample-main-java\target\scala-2.10\classes...

Multiple main classes detected, select one to run:

 [1] sample.hello.Main
 [2] sample.hello.Main2

Enter number: 2

[info] Running sample.hello.Main2
Hello World!
[success] Total time: 3 s, completed 06-Jul-2015 12:33:50
$ cat testFile.log
202  [Hello-akka.actor.default-dispatcher-4] INFO 
 akka.event.slf4j.Slf4jLogger - Slf4jLogger started
244  [Hello-akka.actor.default-dispatcher-3] INFO 
 sample.hello.Main2$Terminator - akka://Hello/user/helloWorld has 
terminated, shutting down system




You could check the Logback docs for instructions on how to use the 
SiftAppender, or ask on their mailing list?
(It does seem a bit rubbish that the SiftAppender will silently fail if 
misconfigured in this way.)

Good luck,


Rich


On Saturday, July 4, 2015 at 7:21:36 AM UTC+1, Aqua Pevi wrote:
>
> Hi,
>
> I tried to turn on logback file logger for the sample using the template 
> at http://www.typesafe.com/activator/template/akka-sample-main-java
>
> That does not log to a file as well. Just the console.
>
> I am assuming the UI uses sbt run to run the app.
>
>
>
>
> On Thursday, July 2, 2015 at 7:16:03 PM UTC+10, Richard Bradley wrote:
>>
>> It looks like it should work.
>> How are you running the application? "sbt run"?
>>
>> Are you able to post the code to github?
>>
>>
>> On Wednesday, July 1, 2015 at 3:20:54 PM UTC+1, Aqua Pevi wrote:
>>>
>>> Hi,
>>>
>>> I have a simple Akka application based off of akka-sample-main-java 
>>> template. 
>>> I am trying to log into a log file rather than the STDOUT. The pom.xml has 
>>> dependencies on akka-actor, akka-slf4j and logback-classic. The 
>>> following are my application.conf and logback.xml. Both are placed in 
>>> src/main/resources.
>>>
>>> application.conf
>>> akka {
>>>   
>>>   loggers = ["akka.event.slf4j.Slf4jLogger"]
>>> stdout-loglevel = "OFF"
>>> }
>>>
>>> logback.xml
>>>
>>> <configuration>
>>>
>>> <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
>>> <!-- encoders are assigned the type 
>>> ch.qos.logback.classic.encoder.PatternLayoutEncoder 
>>> by default -->
>>> <encoder>
>>> <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
>>> </pattern>
>>> </encoder>
>>> </appender>
>>>
>>> <appender name="FILE" 
>>> class="ch.qos.logback.classic.sift.SiftingAppender">
>>> <!-- Set the value via Mapped Diagnostic Context (MDC) in code. -->
>>> <discriminator>
>>> <key>logBasename</key>
>>> <defaultValue>Test</defaultValue>
>>> </discriminator>
>>>
>>> <sift>
>>> <appender name="FILE-${LogBasename}"
>>> class="ch.qos.logback.core.rolling.RollingFileAppender">
>>> <rollingPolicy 
>>> class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
>>> <fileNamePattern>log/application.log</fileNamePattern>
>>> <maxHistory>30</maxHistory>
>>> <timeBasedFileNamingAndTriggeringPolicy
>>> class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
>>> <!-- or whenever the file size reaches 5MB -->
>>> <maxFileSize>5MB</maxFileSize>
>>> </timeBasedFileNamingAndTriggeringPolicy>
>>> </rollingPolicy>
>>> <encoder>
>>> </encoder>
>>> </appender>
>>> </sift>
>>> </appender>
>>>
>>> <root level="INFO">
>>> <appender-ref ref="FILE" />
>>> <!-- <appender-ref ref="STDOUT" /> -->
>>> </root>
>>> </configuration>
>>>
>>> Even with STDOUT turned off in application.conf, the logs are shown in 
>>> the console and not in the logs. In fact,, no logs are created.
>>>
>>> Can some one help me with this, please?
>>>
>>> Thanks!
>>>
>>

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to