micrologmicrolog.sourceforge.net/downloads/microlog-presentation.pdf · 2005. 12. 12. · afile...
TRANSCRIPT
![Page 1: MicroLogmicrolog.sourceforge.net/downloads/MicroLog-Presentation.pdf · 2005. 12. 12. · Afile named microlog.properties in the midlet-root contains the properties/values. User can](https://reader033.vdocuments.us/reader033/viewer/2022061003/60b230aae9e8035e515cc2a6/html5/thumbnails/1.jpg)
MicroLog
Darius KatzJohan Karlsson
![Page 2: MicroLogmicrolog.sourceforge.net/downloads/MicroLog-Presentation.pdf · 2005. 12. 12. · Afile named microlog.properties in the midlet-root contains the properties/values. User can](https://reader033.vdocuments.us/reader033/viewer/2022061003/60b230aae9e8035e515cc2a6/html5/thumbnails/2.jpg)
Background
Johan K. noticed the lack of a good logger for the Java ME environment. So he simply sat down and coded the first version of MicroLog and put it on SourceForge. The rest is history...
![Page 3: MicroLogmicrolog.sourceforge.net/downloads/MicroLog-Presentation.pdf · 2005. 12. 12. · Afile named microlog.properties in the midlet-root contains the properties/values. User can](https://reader033.vdocuments.us/reader033/viewer/2022061003/60b230aae9e8035e515cc2a6/html5/thumbnails/3.jpg)
Features overview
Log4j wannabeLog to the consoleLog to RMS (accessible with an included midlet)Log to fileLog to FormLog over Bluetooth (coming real soon)Log over GPRS (coming soon)Flexible formattingConfigurable
![Page 4: MicroLogmicrolog.sourceforge.net/downloads/MicroLog-Presentation.pdf · 2005. 12. 12. · Afile named microlog.properties in the midlet-root contains the properties/values. User can](https://reader033.vdocuments.us/reader033/viewer/2022061003/60b230aae9e8035e515cc2a6/html5/thumbnails/4.jpg)
Using MicroLog
//Init the loggerLogger log = Logger.getLogger();log.configure(properties);......log.info(“Log this text”);
![Page 5: MicroLogmicrolog.sourceforge.net/downloads/MicroLog-Presentation.pdf · 2005. 12. 12. · Afile named microlog.properties in the midlet-root contains the properties/values. User can](https://reader033.vdocuments.us/reader033/viewer/2022061003/60b230aae9e8035e515cc2a6/html5/thumbnails/5.jpg)
Using MicroLog
//Init the loggerLogger log = Logger.getLogger();log.configure(properties);......log.info(“Log this text”);
?
![Page 6: MicroLogmicrolog.sourceforge.net/downloads/MicroLog-Presentation.pdf · 2005. 12. 12. · Afile named microlog.properties in the midlet-root contains the properties/values. User can](https://reader033.vdocuments.us/reader033/viewer/2022061003/60b230aae9e8035e515cc2a6/html5/thumbnails/6.jpg)
Properties
Properties is a module in MicroLog which helps to set up the Logger. Example:
microlog.level=DEBUGmicrolog.appender=net.sf.microlog.appender.RecordStoreA...microlog.appender.RecordStoreAppender.maxLogEntries=20microlog.formatter=net.sf.microlog.format.SimpleFormatter
Line 2 in all its glory:microlog.appender=net.sf.microlog.appender.RecordStoreAppender;net.sf.microlog.appender.ConsoleAppendernote: two Appenders
![Page 7: MicroLogmicrolog.sourceforge.net/downloads/MicroLog-Presentation.pdf · 2005. 12. 12. · Afile named microlog.properties in the midlet-root contains the properties/values. User can](https://reader033.vdocuments.us/reader033/viewer/2022061003/60b230aae9e8035e515cc2a6/html5/thumbnails/7.jpg)
Property sources
4 different sources today: Default values Property file Application properties (attributes) Numbered application properties (attributes)
![Page 8: MicroLogmicrolog.sourceforge.net/downloads/MicroLog-Presentation.pdf · 2005. 12. 12. · Afile named microlog.properties in the midlet-root contains the properties/values. User can](https://reader033.vdocuments.us/reader033/viewer/2022061003/60b230aae9e8035e515cc2a6/html5/thumbnails/8.jpg)
Default values
Class is called DefaultValuesHardcoded in the class. Used if not changed by user in another property source.All “system properties” should be included. (In our case everything that MicroLog uses.)
![Page 9: MicroLogmicrolog.sourceforge.net/downloads/MicroLog-Presentation.pdf · 2005. 12. 12. · Afile named microlog.properties in the midlet-root contains the properties/values. User can](https://reader033.vdocuments.us/reader033/viewer/2022061003/60b230aae9e8035e515cc2a6/html5/thumbnails/9.jpg)
Property file
Class is called PropertyFileA file named microlog.properties in the midlet-root contains the properties/values.User can change the default values.User can add own values.
Example:microlog.level=DEBUGmicrolog.appender=net.sf.microlog.appender.RecordStoreA...microlog.appender.RecordStoreAppender.maxLogEntries=20microlog.formatter=net.sf.microlog.format.SimpleFormatter
![Page 10: MicroLogmicrolog.sourceforge.net/downloads/MicroLog-Presentation.pdf · 2005. 12. 12. · Afile named microlog.properties in the midlet-root contains the properties/values. User can](https://reader033.vdocuments.us/reader033/viewer/2022061003/60b230aae9e8035e515cc2a6/html5/thumbnails/10.jpg)
Application properties
Class is called AppPropertyProperties are added in the jad-file or in the manifest-file as usual attributes (property:value) User can change the default values.User can override the values in the properties file.User can not add own values.
![Page 11: MicroLogmicrolog.sourceforge.net/downloads/MicroLog-Presentation.pdf · 2005. 12. 12. · Afile named microlog.properties in the midlet-root contains the properties/values. User can](https://reader033.vdocuments.us/reader033/viewer/2022061003/60b230aae9e8035e515cc2a6/html5/thumbnails/11.jpg)
Numbered application props
Class is called NumberedAppPropertyProperties are added in the jad-file or in the manifest-file as attributes in a special way: AppProperty_1 : MyProperty=MyValue AppProperty_2 : MyOtherProperty=MyOtherValue AppProperty_3 : SomeOtherProperty=SomeOtherValue
User can change the default values.User can override the values in the properties file and the values set in application properties.User can add own values.
![Page 12: MicroLogmicrolog.sourceforge.net/downloads/MicroLog-Presentation.pdf · 2005. 12. 12. · Afile named microlog.properties in the midlet-root contains the properties/values. User can](https://reader033.vdocuments.us/reader033/viewer/2022061003/60b230aae9e8035e515cc2a6/html5/thumbnails/12.jpg)
Repetition
Values are read in the following order:1.DefaultValues2.PropertyFile3.AppProperty4.NumberedAppProperty
Each new level overrides the same properties in the previous levels.
![Page 13: MicroLogmicrolog.sourceforge.net/downloads/MicroLog-Presentation.pdf · 2005. 12. 12. · Afile named microlog.properties in the midlet-root contains the properties/values. User can](https://reader033.vdocuments.us/reader033/viewer/2022061003/60b230aae9e8035e515cc2a6/html5/thumbnails/13.jpg)
Using Properties
//Create a new properties in the MIDlet classProperties properties = new Properties(this);...
...myString = (String)properties.get(“MyProperty”);myString = properties.getString(“MyProperty”);...
this is the midlet
![Page 14: MicroLogmicrolog.sourceforge.net/downloads/MicroLog-Presentation.pdf · 2005. 12. 12. · Afile named microlog.properties in the midlet-root contains the properties/values. User can](https://reader033.vdocuments.us/reader033/viewer/2022061003/60b230aae9e8035e515cc2a6/html5/thumbnails/14.jpg)
Finally
Use Properties in your own mobile applications
![Page 15: MicroLogmicrolog.sourceforge.net/downloads/MicroLog-Presentation.pdf · 2005. 12. 12. · Afile named microlog.properties in the midlet-root contains the properties/values. User can](https://reader033.vdocuments.us/reader033/viewer/2022061003/60b230aae9e8035e515cc2a6/html5/thumbnails/15.jpg)
Using MicroLog
//Init the loggerLogger log = Logger.getLogger();log.configure(properties);......log.info(“Log this text”);
?X
![Page 16: MicroLogmicrolog.sourceforge.net/downloads/MicroLog-Presentation.pdf · 2005. 12. 12. · Afile named microlog.properties in the midlet-root contains the properties/values. User can](https://reader033.vdocuments.us/reader033/viewer/2022061003/60b230aae9e8035e515cc2a6/html5/thumbnails/16.jpg)
Using MicroLog, the final cut
//Init propertiesProperties properties = new Properties(this);
//Init the loggerLogger log = Logger.getLogger();log.configure(properties);......log.info(“Log this text”);log.error(“Log this error”);
![Page 17: MicroLogmicrolog.sourceforge.net/downloads/MicroLog-Presentation.pdf · 2005. 12. 12. · Afile named microlog.properties in the midlet-root contains the properties/values. User can](https://reader033.vdocuments.us/reader033/viewer/2022061003/60b230aae9e8035e515cc2a6/html5/thumbnails/17.jpg)
MicroLog building blocks
Appenders (“output channels”) ConsoleAppender (to the console) FileAppender (to a file via JSR75, FileConnection API) RecordStoreAppender (to the RMS) FormAppender (to a form) BluetoothAppender (under development) GPRSAppender (to be developed) more...
Formatters (“looks of the output”) SimpleFormatter (predefined, simple) ConfigurableFormatter (under development) more?
![Page 18: MicroLogmicrolog.sourceforge.net/downloads/MicroLog-Presentation.pdf · 2005. 12. 12. · Afile named microlog.properties in the midlet-root contains the properties/values. User can](https://reader033.vdocuments.us/reader033/viewer/2022061003/60b230aae9e8035e515cc2a6/html5/thumbnails/18.jpg)
Popular Appenders
ConsoleAppender Used in emulators Used in P900/P910 with a utility
RecordStoreAppender Used in all mobiles Comes with a MIDlet that views the logs
BluetoothAppender Send logs to the PC Used with mobiles that support Bluetooth
![Page 19: MicroLogmicrolog.sourceforge.net/downloads/MicroLog-Presentation.pdf · 2005. 12. 12. · Afile named microlog.properties in the midlet-root contains the properties/values. User can](https://reader033.vdocuments.us/reader033/viewer/2022061003/60b230aae9e8035e515cc2a6/html5/thumbnails/19.jpg)
How to add to your projectDownload and unpackCopy source-code to your project (JAR-file in the future when the API is finalized) copy microlog.properties if needed
Set properties in application properties OR in microlog.properties file (important: correct CRLF)
Add MIDlet to suite RecordStoreLogViewer (if needed)
Add init code in MIDlet constructor OR in MIDlet startUp() method
Use don't abuse (might slow down)
![Page 20: MicroLogmicrolog.sourceforge.net/downloads/MicroLog-Presentation.pdf · 2005. 12. 12. · Afile named microlog.properties in the midlet-root contains the properties/values. User can](https://reader033.vdocuments.us/reader033/viewer/2022061003/60b230aae9e8035e515cc2a6/html5/thumbnails/20.jpg)
Demo
Live on stage
![Page 21: MicroLogmicrolog.sourceforge.net/downloads/MicroLog-Presentation.pdf · 2005. 12. 12. · Afile named microlog.properties in the midlet-root contains the properties/values. User can](https://reader033.vdocuments.us/reader033/viewer/2022061003/60b230aae9e8035e515cc2a6/html5/thumbnails/21.jpg)
How to add to your projectDownload and unpackCopy source-code to your project (JAR-file in the future when the API is finalized) copy microlog.properties if needed
Set properties in application properties OR in microlog.properties file (important: correct CRLF)
Add MIDlet to suite RecordStoreLogViewer (if needed)
Add init code in MIDlet constructor OR in MIDlet startUp() method
Use don't abuse (might slow down)
![Page 22: MicroLogmicrolog.sourceforge.net/downloads/MicroLog-Presentation.pdf · 2005. 12. 12. · Afile named microlog.properties in the midlet-root contains the properties/values. User can](https://reader033.vdocuments.us/reader033/viewer/2022061003/60b230aae9e8035e515cc2a6/html5/thumbnails/22.jpg)
Code help wanted
BluetoothAppender (BT-expert needed)GprsAppenderMore flexible Formatter perhaps “%d %t %m” etc.
Get hold of stacktrace in exceptionImprove read of microlog.properties fileAnything else you'd likeNon-coding things: Design homepage Tutorials FAQ Manuals
![Page 23: MicroLogmicrolog.sourceforge.net/downloads/MicroLog-Presentation.pdf · 2005. 12. 12. · Afile named microlog.properties in the midlet-root contains the properties/values. User can](https://reader033.vdocuments.us/reader033/viewer/2022061003/60b230aae9e8035e515cc2a6/html5/thumbnails/23.jpg)
Links
MicroLog homepage:http://microlog.sourceforge.net
Project page on SourceForge:http://sf.net/projects/microlog
![Page 24: MicroLogmicrolog.sourceforge.net/downloads/MicroLog-Presentation.pdf · 2005. 12. 12. · Afile named microlog.properties in the midlet-root contains the properties/values. User can](https://reader033.vdocuments.us/reader033/viewer/2022061003/60b230aae9e8035e515cc2a6/html5/thumbnails/24.jpg)
Thank you for listening