0

I am trying to print the log messages on the same line but it prints in the next line

   import java.util.logging.Handler;

   static Logger logger = Logger.getLogger(pdmsMigration.class.getName());
    logger.setUseParentHandlers(false);
    logger.info(String.format("%s_%d.%s, "Processing." + file ));

and prints

    Feb 19, 2020 6:56:30 AM test getdata
    INFO: Processing testFile
    Feb 19, 2020 6:56:30 AM test  getInfo
    INFO: Success

But I want to print it Feb 19, 2020 6:56:30 AM test getdata INFO: Processing testFile

I tried using "\n" and it prints

    Feb 19, 2020 6:56:30 AM test getdata
    INFO: Processing testFile

    Feb 19, 2020 6:56:30 AM test  getInfo
    INFO: Success
Ram Pr
  • 45
  • 5
  • can you show us your `logback.xml` if you are using the `logback` library. If you haven't made a configuration yet. That's the place where you can modify this logging behaviour – tsamridh86 Aug 19 '21 at 01:43
  • I have not used any library. The java file is a standalone program. – Ram Pr Aug 19 '21 at 01:48
  • 1
    You'd have to post your `logging.properties` file - but you can circumvent that for testing purpose by `System.setProperty("java.util.logging.SimpleFormatter.format", "[%1$tF %1$tT] [%4$-7s] %5$s %n");` which is just an example which shows `[2017-05-18 14:03:41] [INFO ] (message)`. Here is full syntax: https://docs.oracle.com/javase/7/docs/api/java/util/Formatter.html#syntax –  Aug 19 '21 at 02:29

0 Answers0