November 18, 2013

How to configure JDK logging for Jersey 2 tests

Jersey uses JDK Logging API to log messages.

One way how to configure JDK Logging is a properties file. In such case you have to set JVM system property java.util.logging.config.file to reference the properties file.

Initially the logging configuration file logging.properties can look:

#All attributes details
handlers=java.util.logging.ConsoleHandler
java.util.logging.ConsoleHandler.level=FINEST
java.util.logging.SimpleFormatter.format=%4$-7s [%3$s] %5$s%6$s%n

#All log level details
.level=INFO
org.glassfish.jersey.level=CONFIG
org.glassfish.jersey.tracing.level=FINEST

The configuration explained:

  • handlers=java.util.logging.ConsoleHandler - log messages are written to System.err
  • java.util.logging.ConsoleHandler.level=FINEST - allow to log FINEST message;
    default is INFO so more detailed messages are suppressed by default
  • java.util.logging.SimpleFormatter.format - example of simple and single line format - just level, logger name and message;
    Note: It just works with Java 7.
  • org.glassfish.jersey.level=CONFIG - example of per-package level configuration;
    log all SEVERE, WARNING, INFO and CONFIG level Jersey messages
  • org.glassfish.jersey.tracing.level=FINEST - example of detailed level configuration of specified package
And as mentioned it is necessary to set system property java.util.logging.config.file. Do you want to see log messages during unit testing (e.g. using maven)? There are two options:

  • run tests in new JVM instance (fork option) and configure the system property in such maven plugin
  • enhance maven command line parameter and add the
    -Djava.util.logging.config.file=... property

For example, run test application using Jetty server for test module tracing-support:

~/jersey2/tests/integration/tracing-support$ mvn compile jetty:run -Djava.util.logging.config.file=src/test/resources/logging.properties

-that's all folks

28 comments:

  1. Replies
    1. Big data is a term that describes the large volume of data – both structured and unstructured – that inundates a business on a day-to-day basis. big data projects for students But it’s not the amount of data that’s important.Project Center in Chennai

      Spring Framework has already made serious inroads as an integrated technology stack for building user-facing applications. Corporate TRaining Spring Framework the authors explore the idea of using Java in Big Data platforms.

      Spring Training in Chennai

      The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training

      Delete
  2. Hey Nice Blog!! Thanks For Sharing!!!Wonderful blog & good post.Its really helpful for me, waiting for a more new post. Keep Blogging!
    SEO company in coimbatore
    Digital Marketing Company in Coimbatore
    SEO Services in coimbatore

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. thanks for sharing this such types topics.
    best AWS Solutions Architect Training in Bangalore
    https://onlineidealab.com/aws-training-in-bangalore/

    ReplyDelete
  5. thanks for imforming about this topics.
    Best AWS Certification course.
    https://onlineidealab.com/aws-certification/


    ReplyDelete
  6. Thank you for excellent article.Great information for new guy like antimalware service executable

    ReplyDelete


  7. 2 of 65
    comment

    Tuhin Pabna
    Attachments
    Nov 28, 2019, 9:29 AM
    to noyon0461


    2 Attachments

    keep up the good work. this is an Assam post. this to helpful, i have reading here all post. i am impressed. thank you. this is our digital marketing training center. This is an online certificate course
    digital marketing training in bangalore / https://www.excelr.com/digital-marketing-training-in-bangalore

    ReplyDelete
  8. Excellent and very cool idea and great content of different kinds of valuable information's. Thanks for sharing such a marvelous post with us and keep blogging...

    Java course

    ReplyDelete
  9. Thanks for information.
    pmp certification hyderabad
    https://360digitmg.com/pmp-training-in-hyderabad
    PMP® certification is de facto project management standard practices. PMP® certification training course at 360digiTMG takes you through a vast project management learning experience that is truly unmatched. Our industry-expert trainers will lead the way as you explore the foundational concept of project management.

    ReplyDelete
  10. Thank you for sharing valuable information.
    visit : Digital MarketingTraining in Chennai

    ReplyDelete
  11. This comment has been removed by the author.

    ReplyDelete
  12. This article is increasing the interest to learn more about this topic. Continue the sharing your new updates, regularly for my future.


    คาสิโนออนไลน์
    ufabet
    ufa
    เว็บบอล
    relx

    ReplyDelete
  13. FOXZ88.NET online casino website Global standard 2020-2021
    คาสิโนออนไลน์

    Betting online gambling reminiscent of UFASCR.COM Baccarat.
    ufabet

    UFABET football betting website, the big brother of all UEFA networks, UFADNA, with an update The first modern system in 2021
    ufa

    Web football i99PRO online lottery casino apply today for free 5000 bonus
    เว็บบอล

    Kardinal Stick Siam - Relx a great promotion. Express delivery in 3 hours.
    relx

    ReplyDelete
  14. Online football betting i99club, one of the world's leading online gambling sites, provides the best prices in football betting
    เว็บแทงบอล

    Ufabet1688 online betting website UEFA Bet is a 100% legal website with all licenses
    ufabet

    UEFA football betting, casino, slots, lottery, direct website 1688, stable financial, 100% UFABET168
    ufa

    Fan wreath shop with free delivery, with pictures before-after sending with receipt.
    พวงหรีด

    Sticking to the COVID-19 situation: Arekorenavi.info
    โควิด

    Online Baccarat FOXZ24 Easy to apply, fast, deposit-withdraw 10 seconds with the system
    บาคาร่า

    ReplyDelete
  15. Online football betting i99club, one of the world's leading online gambling sites, provides the best prices in football betting
    เว็บแทงบอล


    Ufabet1688 online betting website UEFA Bet is a 100% legal website with all licenses
    ufabet


    UEFA football betting, casino, slots, lottery, direct website 1688, stable financial, 100% UFABET168
    ufa


    Fan wreath shop with free delivery, with pictures before-after sending with receipt.
    พวงหรีด


    Sticking to the COVID-19 situation: Arekorenavi.info
    โควิด


    Online Baccarat FOXZ24 Easy to apply, fast, deposit-withdraw 10 seconds with the system
    บาคาร่า

    ReplyDelete
  16. Movie-watching websites that are more than movie-watching websites Because we are the number 1 free movie site in Thailand for a long time, including new movies, Thai movies, Western movies, Asian movies, we have all kinds of ways for you Including new series Full of all stories without interstitial ads to keep annoying anymore. One place sa-movie.com.

    Android and IOS operating systems. Watch online movies, Thai movies, Western movies, Asian movies, Cartoon movies, Netflix Movie, Action Movies, Comedy Movies, Crime Movies, Drama Movies, Horror Movies, Adventure Movies, Crash Movies and still have many new movies to watch. You can watch for free anytime, anywhere 24 hours a day at see4k.com.


    GangManga read manga, read manga, read manga online for free, fast loading, clear images in HD quality, all titles, anywhere, anytime, on mobile, tablet, computer. Android and IOS operating systems. Read top comics, action dramas, comedy, adventure, horror and manga. New coming every day to watch many more. Can be read for free anytime anywhere 24 hours a day at gangmanga.com..

    It is no secret that football is among the most popular and widely watched sports. Everybody who likes football tries to find the best platform for free soccer streaming. So, what are the best free sports streaming sites? We are going to answer this question. On this page, you can find a detailed overview of the most widespread soccer streaming websites. Keep on reading and make the best choice for you live24th.me.

    ReplyDelete
  17. We absolutely love your blog and find almost all of your post’s to be just what I’m looking for. ufabet168 Does one offer guest writers to write content for you personally? I wouldn’t mind publishing a post or elaborating on a number of the subjects you write with regards to here.

    ReplyDelete
  18. Sankey chart is a very useful visualization to show the flow of data. ChartExpo provides you a better and easiest way to create the Sankey Diagram in no time without coding only on few clicks. Read more here : Sankey Diagram Excel
    Read More: https://businessanddigitalmarketing.blogspot.com/2021/07/how-effective-are-google-ads.html .

    ReplyDelete