java - what is best option for creating log message buffer -


i working on web application needs deployed cloud. there cloud service can store log messages applications securely. exposed cloud using rest api can take max 25 log messages in json format. using log4j(open other too) log in file. now, need transition our application move file based logging using cloud rest api.

i considering expensive make rest api call every log message , slow down application.

in context, considering writing custom appender can write buffer. buffer can in-memory or persistent buffer read , emptied periodically separate thread or process sending 25 messages in bunch cloud rest api.

option 1:

using in-memory buffer custom appender write message in memory list , keep filling it. there woudl daemon thread keep removing 25 messages @ time buffer , write cloud using rest api. there downside approach in event of application/server/node crashing.. lose critical log message can lead diagnostic of why crash occurred.i not sure if right way of thinking.

option 2:

using persistent buffer database/message queue:

appender can log message database table temporarily or post message queue processed separate long running job pick messages db or queue , post cloud using rest api.

please guide option looks best.

there lot of build in appender in log4j : https://logging.apache.org/log4j/2.x/manual/appenders.html , if use dedicated service in cloud, may give specific appender. if it's in environment, maybe try stack elk log4j rollingfile apender, technique you'll not lose log entries.


Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -