<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">OK, I found my pitfalls.<div><br></div><div>First, the Android VM is a not really a Java VM, it is a proprietary VM that translates java into its own bytecode. &nbsp;I don't know why they felt this was necessary but it is certainly annoying. &nbsp;</div><div><br></div><div>Second, the Android implementation of the JDK is missing quite a few standard packages like javax.naming, java.lang.management and, of course, javaee classes. &nbsp;So I tried to build an android version of logback in using the android compiler and adding in java framework jars like jndi.jar, jaf.jar,javamail.jar, etc.</div><div><br></div><div>What I got for this was the following compiler message;</div><div><br></div><div><div><div style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 8.5pt; font-family: Monaco, serif; color: rgb(255, 27, 24); ">Attempt to include a core class (java.* or javax.*) in something other<o:p></o:p></span></div></div><div><div style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 8.5pt; font-family: Monaco, serif; color: rgb(255, 27, 24); ">than a core library. It is likely that you have attempted to include<o:p></o:p></span></div></div><div><div style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 8.5pt; font-family: Monaco, serif; color: rgb(255, 27, 24); ">in an application the core library (or a part thereof) from a desktop<o:p></o:p></span></div></div><div><div style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 8.5pt; font-family: Monaco, serif; color: rgb(255, 27, 24); ">virtual machine. This will most assuredly not work. At a minimum, it<o:p></o:p></span></div></div><div><div style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 8.5pt; font-family: Monaco, serif; color: rgb(255, 27, 24); ">jeopardizes the compatibility of your app with future versions of the<o:p></o:p></span></div></div><div><div style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 8.5pt; font-family: Monaco, serif; color: rgb(255, 27, 24); ">platform. It is also often of questionable legality.<o:p></o:p></span></div></div><div><div style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 8.5pt; font-family: Monaco, serif; "><o:p>&nbsp;</o:p></span></div></div><div><div style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 8.5pt; font-family: Monaco, serif; color: rgb(255, 27, 24); ">If you really intend to build a core library -- which is only<o:p></o:p></span></div></div><div><div style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 8.5pt; font-family: Monaco, serif; color: rgb(255, 27, 24); ">appropriate as part of creating a full virtual machine distribution,<o:p></o:p></span></div></div><div><div style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 8.5pt; font-family: Monaco, serif; color: rgb(255, 27, 24); ">as opposed to compiling an application -- then use the<o:p></o:p></span></div></div><div><div style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 8.5pt; font-family: Monaco, serif; color: rgb(255, 27, 24); ">"--core-library" option to suppress this error message.<o:p></o:p></span></div></div><div><div style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 8.5pt; font-family: Monaco, serif; "><o:p>&nbsp;</o:p></span></div></div><div><div style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 8.5pt; font-family: Monaco, serif; color: rgb(255, 27, 24); ">If you go ahead and use "--core-library" but are in fact building an<o:p></o:p></span></div></div><div><div style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 8.5pt; font-family: Monaco, serif; color: rgb(255, 27, 24); ">application, then be forewarned that your application will still fail<o:p></o:p></span></div></div><div><div style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 8.5pt; font-family: Monaco, serif; color: rgb(255, 27, 24); ">to build or run, at some point. Please be prepared for angry customers<o:p></o:p></span></div></div><div><div style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 8.5pt; font-family: Monaco, serif; color: rgb(255, 27, 24); ">who find, for example, that your application ceases to function once<o:p></o:p></span></div></div><div><div style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 8.5pt; font-family: Monaco, serif; color: rgb(255, 27, 24); ">they upgrade their operating system. You will be to blame for this<o:p></o:p></span></div></div><div><div style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 8.5pt; font-family: Monaco, serif; color: rgb(255, 27, 24); ">problem.<o:p></o:p></span></div></div><div><div style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 8.5pt; font-family: Monaco, serif; "><o:p>&nbsp;</o:p></span></div></div><div><div style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 8.5pt; font-family: Monaco, serif; color: rgb(255, 27, 24); ">If you are legitimately using some code that happens to be in a core<o:p></o:p></span></div></div><div><div style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 8.5pt; font-family: Monaco, serif; color: rgb(255, 27, 24); ">package, then the easiest safe alternative you have is to repackage<o:p></o:p></span></div></div><div><div style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 8.5pt; font-family: Monaco, serif; color: rgb(255, 27, 24); ">that code. That is, move the classes in question into your own package<o:p></o:p></span></div></div><div><div style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 8.5pt; font-family: Monaco, serif; color: rgb(255, 27, 24); ">namespace. This means that they will never be in conflict with core<o:p></o:p></span></div></div><div><div style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 12pt; font-family: 'Times New Roman', serif; "><span style="font-size: 8.5pt; font-family: Monaco, serif; color: rgb(255, 27, 24); ">system classes.&nbsp;</span><span class="apple-style-span"><span style="font-family: Monaco, serif; color: rgb(255, 27, 24); "><font class="Apple-style-span" size="3"><span class="Apple-style-span" style="font-size: 11px;">If you find that you cannot do this, then that is an</span></font></span></span><span style="font-family: Monaco, serif; color: rgb(255, 27, 24); "><font class="Apple-style-span" size="3"><span class="Apple-style-span" style="font-size: 11px;"><o:p></o:p></span></font></span></div></div><div><div style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-family: 'Times New Roman', serif; "><span class="apple-style-span"><span style="font-family: Monaco, serif; color: rgb(255, 27, 24); "><font class="Apple-style-span" size="3"><span class="Apple-style-span" style="font-size: 11px;">indication that the path you are on will ultimately lead to pain,</span></font></span></span><span style="font-family: Monaco, serif; color: rgb(255, 27, 24); "><font class="Apple-style-span" size="3"><span class="Apple-style-span" style="font-size: 11px;"><o:p></o:p></span></font></span></div></div><div><div style="margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-family: 'Times New Roman', serif; "><span class="apple-style-span"><span style="font-family: Monaco, serif; color: rgb(255, 27, 24); "><font class="Apple-style-span" size="3"><span class="Apple-style-span" style="font-size: 11px;">suffering, grief, and lamentation.</span></font></span></span></div></div></div><div><br></div><div>This strikes me as good advice. &nbsp;I don't really have the time to hunt down the source code for all those packages and add them under special package structures so, instead, I started removing classes.</div><div><br></div><div>I was able to get logback classic to compile in android by removing these classes and packages;</div><div><br></div><div>ch.qos.logback.classic.</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>boolex.GEventEvaluator.java</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>boolex.JaninoEventEvaluator.java</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>gaffer.GafferUtil.java &nbsp;(Removing Groovy just made things easier for me)</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>helpers/MDCInsertingServletFilter.java</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>net/JMS*.java &nbsp;(Gutted all JMS features)</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>selector/servlet/*</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>ViewStatusMessageServlet.java</div><div><br></div><div>I also commented out some features to allow compilation that I figured I wouldn't need (mostly relating to Groovy).</div><div><br></div><div>So, I got logback-classic to compile but for the life of me I can't seem to overcome a NoClassDefFound error for slf4.LogFactory. I've tried everything I can think of to ensure a clean path &nbsp;but I keep getting this error. &nbsp;I even unwrapped slf4j and compiled it into my logback4android project. &nbsp;Again, everything compiles nicely but it gets confused trying to load that class. &nbsp;</div><div><br></div><div>If anyone has any ideas or suggesstions I'd love to hear them.</div><div><br></div><div>Robert Schmid</div><div><br></div><div><br></div><div><br><div><div>On Aug 6, 2010, at 4:36 PM, Ceki Gulcu wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>On 06.08.2010 23:25, Robert Schmid wrote:<br><blockquote type="cite">I am about to implement an appender that I can use on Android. I'm<br></blockquote><blockquote type="cite">guessing it won't be much more difficult than doing the same from log4j.<br></blockquote><blockquote type="cite">The primary problem is that we can't really use java.io.File to access<br></blockquote><blockquote type="cite">the file system. Android has its own File access API. I believe that<br></blockquote><blockquote type="cite">this will be as simple as extending RollingFileAppender and overriding<br></blockquote><blockquote type="cite">methods as needed to swap out the File access apis.<br></blockquote><br>Sounds good.<br><br><blockquote type="cite">Can anybody spot the flaw in my thinking? Are there other pitfalls I<br></blockquote><blockquote type="cite">need to worry about?<br></blockquote><br>No, not really, Anyway, if you run into trouble, just holler.<br><br><blockquote type="cite"><br></blockquote><blockquote type="cite">Robert Schmid<br></blockquote>_______________________________________________<br>Logback-user mailing list<br><a href="mailto:Logback-user@qos.ch">Logback-user@qos.ch</a><br>http://qos.ch/mailman/listinfo/logback-user<br></div></blockquote></div><br><div>
<span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div><br></div></span></div></div></body></html>