![]() |
#1 |
Junior Member
![]() Posts: 3
Karma: 10
Join Date: Dec 2013
Device: kindle 4
|
log4j on the kindle
Hi,
I hope someone can help me. I'm trying to log some output of my kindlet, but I didn't get any log file. I tried two versions of my propertie file, but it didn't work. So what could be wrong? Is the propertie file not correct? In which directory it should be on the kindle? Could anyone help me please? Thanks in advance. The code of the programm is: Code:
package kindlebeispiel; import com.amazon.kindle.kindlet.AbstractKindlet; import com.amazon.kindle.kindlet.KindletContext; import com.amazon.kindle.kindlet.ui.KTextArea; import org.apache.log4j.Logger; public class Main extends AbstractKindlet { private static final Logger log = Logger.getLogger(Main.class); public void create(KindletContext context) { log.debug("test1"); this.ctx = context; } public void start() { try { log.debug("test2"); ctx.getRootContainer().add(new KTextArea("Hello World")); } catch (Throwable t) { t.printStackTrace(); } } public void stop() { } public void destroy() { } } Code:
log4j.rootLogger=DEBUG log4j.appender.R=org.apache.log4j.FileAppender log4j.appender.R.File=log4j.log log4j.appender.R.layout=org.apache.log4j.PatternLayout log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n Code:
log4j.rootLogger=debug, R log4j.category.kindle.KindleTerminal=info log4j.category.kindle.KindleTerminal$Redrawer=warn log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout # Pattern to output the caller's file name and line number. log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n log4j.appender.R=org.apache.log4j.RollingFileAppender log4j.appender.R.File=/mnt/us/developer/kindlebeispiel/work/kindlebeispiel.log log4j.appender.R.MaxFileSize=100KB # Keep one backup file log4j.appender.R.MaxBackupIndex=1 log4j.appender.R.layout=org.apache.log4j.PatternLayout log4j.appender.R.layout.ConversionPattern=%d{dd MMM HH:mm:ss} %5p [%t] (%F:%L) - %m%n |
![]() |
![]() |
![]() |
#2 |
Going Viral
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 17,212
Karma: 18210809
Join Date: Feb 2012
Location: Central Texas
Device: No K1, PW2, KV, KOA
|
check if logging is disabled at a system's level.
seems to me that was the problem (and solution) last time someone asked about this. |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Junior Member
![]() Posts: 3
Karma: 10
Join Date: Dec 2013
Device: kindle 4
|
Sorry for the stupid question, but I haven't the KDK.
Where can I check that logging is disabled? Can you tell me the path please. |
![]() |
![]() |
![]() |
#4 |
Guru
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 608
Karma: 1588610
Join Date: Jan 2012
Device: Kindle Scribe
|
If the thing logs to a file, you will need a kindle jailbreak. See the kual sticky prereqs. Note that you cannot publish to amazon if you've used the kindlet jb
|
![]() |
![]() |
![]() |
#5 |
Going Viral
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 17,212
Karma: 18210809
Join Date: Feb 2012
Location: Central Texas
Device: No K1, PW2, KV, KOA
|
|
![]() |
![]() |
Advert | |
|
![]() |
#6 |
(offline)
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,907
Karma: 6736094
Join Date: Dec 2011
Device: K3, K4, K5, KPW, KPW2
|
@dragon123: You're not providing enough information. Are you getting an error? If so, which? Did you bundle log4j with your application, or make sure that log4j is actually supported?
The actual file that you want to be logging to seems ok, i.e., that directory should be accessible and writable from a Kindlet without the Kindlet jailbreak. Still, I think that log4j is a massive overkill for what you're trying to do. If all you want to do is output some text to a file, I suggest to simply write an extremely simple Logging utility yourself. I'm using this trivial peace of code in JBPatch. You could of course create something more prowerful, with logging levels etc. - but it will still be MUCH less complicated than using a full-blown logging framework like log4j. |
![]() |
![]() |
![]() |
#7 | |
Groupie
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 164
Karma: 164969
Join Date: Dec 2011
Device: Palm IIIx, (iPhone|Kindle) Touch
|
Quote:
![]() In my HackedUpReaderKindlet I'm putting the log4j.properties into the same directory in the azw2 file as the other class files and I am loading it manually. You can have a look at it on github: https://github.com/bhaak/HackedUpRea...erKindlet.java |
|
![]() |
![]() |
![]() |
#8 | ||
Groupie
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 164
Karma: 164969
Join Date: Dec 2011
Device: Palm IIIx, (iPhone|Kindle) Touch
|
Quote:
Quote:
|
||
![]() |
![]() |
![]() |
#9 | |
(offline)
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,907
Karma: 6736094
Join Date: Dec 2011
Device: K3, K4, K5, KPW, KPW2
|
Quote:
![]() That said, I personally dislike log4j for reasons I can't really explain... maybe I'm spoilt by past experiences with it. ... And IMO, the usual Kindlet isn't exactly a complex application server that requires extensive logging with 7 different log levels, log file rotation etc. As the saying goes: "use the right tools for the right job". In my particular case, the trivial solution was enough. In other cases, a more complex and powerful solution may be better. |
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Kindle Nicknaming Scheme, Using Kindle with Calibre, and Hacking the Kindle | Klif | Amazon Kindle | 11 | 09-12-2012 05:11 PM |
$0.01 in Kindle Store: Interactive Sudoku for Kindle 2 and Kindle DX - Volume 1 | Xia | Deals and Resources (No Self-Promotion or Affiliate Links) | 2 | 11-07-2009 10:06 AM |