1

we need log a large messages which we receive as response from external services.

This response can be a bigger json or xml, which can has up to 50 mb.

what is the best practise for that? Can we log simple like logger.info(payload)?

Thank you for answers.

Denis Stephanov
  • 4,563
  • 24
  • 78
  • 174
  • 1
    `info` is wrong level for that. It should be rather `trace`. – Max Farsikov Sep 09 '19 at 13:14
  • @MaxFarsikov this was just example. For this logger will be appender which only logs files. And we need log these files always. Question is if this logging bigger files is technicaly ok. – Denis Stephanov Sep 09 '19 at 13:37
  • 1
    No issues at all. As long as you have and can afford disk space for these, feel free. Logs are meant for this purpose only. Again deciding on info, debug, trace, error - it all depends on your business needs. But be careful about the compliance and regulations for PHI or PII related information in the logs. Better consult with the legal team of your enterprise. – Ajay Kumar Sep 09 '19 at 14:50

1 Answers1

2

This is not recommended in production, as it affects efficiency of log files usages. Also it raises security concerns if the message has sensitive data.

If it still needs to be done, one of below approaches can be used:

  1. Log the message in debug level logger.debug(payload)
  2. Use FileAppender to write the message to file
kann
  • 687
  • 10
  • 22