Properties File and Short Class names

Help
YanXu
2009-08-10
2013-04-26
  • YanXu
    YanXu
    2009-08-10

    Hi!

    First of all, great piece of work so far! Though I had too reconfigure the Jar file because I'm using IM Profile instead of MID Profile which lacks of GUI and other stuff.

    Now, I have two questions:
    1.) I tried to use the following properties file (according to the demo file)
    microlog.rootLogger=TRACE, A1
    microlog.appender.A1=net.sf.microlog.core.appender.ConsoleAppender
    microlog.appender.A1.formatter=net.sf.microlog.common.format.PatternFormatter
    microlog.appender.A1.formatter.pattern=[%P][%d][%c] %m

    which always says "No appender is set, using ConsoleAppender..."

    Then I tried

    microlog.level=TRACE
    microlog.appender=net.sf.microlog.core.appender.ConsoleAppender
    microlog.appender.formatter=net.sf.microlog.common.format.PatternFormatter
    microlog.appender.formatter.pattern=[%P][%d][%c] %m

    Which works... !?! Any suggestions how to fix it?
    2.)
    Is it possible to automatically truncate the absolute class name by cutting off the package? I wrote a litte helper class that does the trick before calling getLogger. But is it possible to do this "natively"? It would be nice to have %C : absolute class name and %c relative class name or something like that. I saw the format.command.CategoryCommand class. Can I use this too hook in my own Formatter Class somehow?

    Thanks, Jan

     
    • Johan Karlsson
      Johan Karlsson
      2009-08-15

      Hi,

      I have been on vacation on not been able to answer these questions before. Sorry for the late reply.

      Here are my answers:

      1) The first line should be
      microlog.logger=TRACE,A1

      2) It is not possible today, but something that I would like to add.

      If you would like to do your own formatter, just make an implementation of the Formatter interface.

      Regards
      Johan

       
  • Hi,

    2) This was such a good idea that I have implemented it. It will be available in the final 2.0 release. Expect this to be finished within a couple of days.

    Regards
    Johan

     
  • Johan Karlsson
    Johan Karlsson
    2009-10-06

    BTW I have re-arranged the jar files. The MIDP part is separated from the rest of the stuff. There is now a Microlog Core which is independent on the profile, that is it is only dependent on CLDC. This way you should not be forced to do your own jar.

    Regards
    Johan

     
  • Wow…lucky that I activated mail notification…I thought this forum is dead :)

    Johan, I'm glad you like the idea. Thank you for implementing this since it simplifies the output. And also thanks for rearranging the Jar files. I will test this later.

    Cheers, jan

     
  • Johan Karlsson
    Johan Karlsson
    2009-10-06

    Hi,

    the forum is more like asleep :) This is my sparetime project and I have been busy with other things. However for the last couple of weeks I have been working more intensive on Microlog.

    The final 2.0 release is really close… Watch out for it!

    Regards
    Johan

     
  • YanXu
    YanXu
    2009-10-06

    Ahh, good to know!

    Though, I'm not sure if I understood you correctly, did you already released the splitted version (core, midp..) or will it be released together with the final 2.0? Since I didn't find it on SF, I guess not but I just want to confirm.

     
  • Johan Karlsson
    Johan Karlsson
    2009-10-06

    Hi,

    this is not available in any snapshot release. I guess that there will be no snapshot release with this structure before the final release.

    Regards
    Johan

     
  • YanXu
    YanXu
    2009-10-13

    Hi Johan,

    I'm still having problem setting different appeders and levels to differet packages. I tried:

        # This is the microlog configuration tool
        microlog.level=TRACE
        microlog.appender=net.sf.microlog.core.appender.ConsoleAppender
        microlog.appender.formatter=net.sf.microlog.common.format.PatternFormatter
        microlog.appender.formatter.pattern= %m
        com.ettex.jpymite.vm=INFO
        # End of file. Do not remove this line.

    I wanted all classes to use the TRACE level except classes that are located in com.ettex.jpymite.vm and below. They should use INFO But it didn't work. Still all output is at TRACE level!

    Then I changed the first line to

        microlog.level=INFO

    to set all output to INFO. But still, debug mesages are output.

    What am I doing wrong?

    Thanks, Jan

     
  • Hi,

    please take a look at the PropertyConfiguratorV2 and micrologV2.properties for an example on how to solve it.

    Meantime I am writing an article on how to use the new  Microlog version. Also there is a new configuration guide on its way.

    Regards
    Johan

     
  • YanXu
    YanXu
    2009-10-13

    HI… I downloaded the new version and used only the core components.

    I used the following config:

        # This is the microlog configuration tool
        microlog.appender.A1=net.sf.microlog.core.appender.ConsoleAppender
        microlog.appender.A1.formatter=net.sf.microlog.common.format.PatternFormatter
        #microlog.appender.A1.formatter.pattern= %m
        microlog.appender.A1.formatter.pattern=%c{1}  %m %T
        com.ettex=INFO
        com.ettex.rialto=DEBUG
        com.ettex.jpymite.vm=INFO
        # End of file. Do not remove this line.

    On the output I could see a lot of strange things going on… :)

        Trying to load properties from /microlog.properties
        Method…………: 25675a4 'net/sf/microlog/core/PropertyConfigurator.setRootLevel (virtual)'
        Stack Chunk…….: 23700ac
        Frame Pointer…..: 23701f8
        Current IP……..: 2566dda = 2566dc4 + offset 22
        Previous Frame….: 23701d0
        Previous IP…….: 2566e0e (offset 14)
        Frame size……..: 4 (2 arguments, 2 local variables)
        Argument…….: 2562368
        Argument…….: 256a674
        Local……….: 2380f30
        Local……….: 238148c
        Operand……..: 238148c
        Operand……..: 2380f30
       
        Method…………: 2567584 'net/sf/microlog/core/PropertyConfigurator.doConfigureLogLevel (virtual)'
        Stack Chunk…….: 23700ac
        Frame Pointer…..: 23701d0
        Current IP……..: 2566e0e = 2566e00 + offset 14
        Previous Frame….: 23701ac
        Previous IP…….: 2566e15 (offset 5)
        Frame size……..: 3 (2 arguments, 1 local variables)
        Argument…….: 2562368
        Argument…….: 25652c8
        Local……….: 256a674
       
        Method…………: 2567564 'net/sf/microlog/core/PropertyConfigurator.configureMicrologClassicStyle (virtual)'
        Stack Chunk…….: 23700ac
        Frame Pointer…..: 23701ac
        Current IP……..: 2566e15 = 2566e10 + offset 5
        Previous Frame….: 237018c
        Previous IP…….: 25672e8 (offset 24)
        Frame size……..: 2 (2 arguments, 0 local variables)
        Argument…….: 2562368
        Argument…….: 25652c8
       
        Method…………: 2567424 'net/sf/microlog/core/PropertyConfigurator.configure (virtual)'
        Stack Chunk…….: 23700ac
        Frame Pointer…..: 237018c
        Current IP……..: 25672e8 = 25672d0 + offset 24
        Previous Frame….: 2370168
        Previous IP…….: 256732b (offset 51)
        Frame size……..: 3 (2 arguments, 1 local variables)
        Argument…….: 2562368
        Argument…….: 25652c8
        Local……….: 0
       
        Method…………: 2567404 'net/sf/microlog/core/PropertyConfigurator.configure (static)'
        Stack Chunk…….: 23700ac
        Frame Pointer…..: 2370168
        Current IP……..: 256732b = 25672f8 + offset 51
        Previous Frame….: 2370144
        Previous IP…….: 256e905 (offset 17)
        Frame size……..: 3 (1 arguments, 2 local variables)
        Argument…….: 256f43c
        Local……….: 25652c8
        Local……….: 2562368

    This output is going on like this until the end. No "real" output that I wanted is shown. And then comes the following:

        VM status:
        Instruction pointer.: 2566dda (offset within invoking method: 22)
        Next instruction….: 0xb6
        Frame pointer…….: 23701f8
        Local pointer…….: 23701e8
        Stack size……….: 256; sp: 2370214; ranges: 23700b4-23702b4;2564998-2564b98;
        Contents of the current stack frame:
            23701e8: 2562368 (lp)
            23701ec: 256a674
            23701f0: 2380f30
            23701f4: 238148c
            23701f8: 23701d0 (fp)
            23701fc: 2566e0e
            2370200: 23701e4
            2370204: 25675a4
            2370208: 23700ac
            237020c: 0 (end of frame)
            2370210: 238148c
            2370214: 2380f30 (sp)
        Execution stack contains 356 items:
        2370a6c 
        238029c 
        237087c 
        0 
        0 
        0 
        0 
        1 
        24ee4c8 
        10295954 
        23700ac 
        0 
        238029c 
        237087c 
        256f7ec 
        24ee4e4 
        23801c0 
        24ee4f8 
        10274b20 
        24ee4c4 
        23700cc 
        103ce331 
        23700e4 
        10233084 
        23700ac 
        0 
        238104c 
        2370104 
        1033a490 
        237011c 
        10253fa4 
        23700ac 
        0 
        10049110 
        238104c 
        5 
        2370120 
        10369ef4 
        2370138 
        256e9c4 
        23700ac 
        0 
        256f43c 
        25652c8 
        2562368 
        2370144 
        256e905 
        2370158 
        2567404 
        23700ac 
        0 
        2562368 
        25652c8 
        0 
        2370168 
        256732b 
        237017c 
        2567424 
        23700ac 
        0 
        2562368 
        25652c8 
        237018c 
        25672e8 
        23701a0 
        2567564 
        23700ac 
        0 
        2562368 
        25652c8 
        256a674 
        23701ac 
        2566e15 
        23701c0 
        2567584 
        23700ac 
        0 
        2562368 
        256a674 
        2380f30 
        238148c 
        23701d0 
        2566e0e 
        23701e4 
        25675a4 
        23700ac 
        0 
        238148c 
        2380f30 
       
        Execution completed.
        3555793 bytecodes executed
        1416 thread switches
        1700 classes in the system (including system classes)
        19950 dynamic objects allocated (700060 bytes)
        21 garbage collections (610044 bytes collected)
        Execution completed.
        3555793 bytecodes executed
        1416 thread switches
        1700 classes in the system (including system classes)
        19950 dynamic objects allocated (700060 bytes)
        21 garbage collections (610044 bytes collected)
        ALERT: java/lang/NoSuchMethodError: No such method setLevel.(Lnet/sf/microlog/core/Level;)V.
        ricoh-run:
        semc-icon-assembly:

    Note the "ALTERT" saying setLevel, no such method…

    What's the problem? thanks!

    Jan

     
  • Johan Karlsson
    Johan Karlsson
    2009-10-13

    This is actually a crash dump from the WTK. It think that you have to create a new project from scratch and import the Microlog core and MIDP jars once again. There seems to be some kind of missmatch. I have tried the same configuration in Suns WTK without any problems. Tested both Eclispe and NetBeans.

    Regards
    Johan

     
  • Johan Karlsson
    Johan Karlsson
    2009-10-13

    BTW try to remove the first line of the configuration file as well. There is a bug in Microlog that might be triggered by this.

    Regards
    Johan

     
  • Johan Karlsson
    Johan Karlsson
    2009-10-22

    Please download the latest snapshot and try it out.

    Regards
    Johan