Log4j2 Is it possible to get rollingfile to be created immediately under specified conditions? [duplicate] - spring

This question already has an answer here:
How can I configure Log4j2 to roll log files eagerly?
(1 answer)
Closed 8 months ago.
I have set the daily rollingfile settings.
The result works as intended, but there is a problem with the process.
For example, the log for January 1st was written and on January 2nd I wanted the log for January 1st to be rolled immediately.
However, in reality, this is not the case, and at least one log of January 2nd must occur before rolling works.
That is, if no new dated log occurs, the old log is not rolled out and is still maintained.
Is there any way to make it roll immediately according to the rollingfile condition?

You could use the CronTriggeringPolicy configured to trigger every day at midnight instead of the TimeBasedTriggeringPolicy for the daily rollover you already have, e.g.
<RollingFile ...>
...
<Policies>
<CronTriggeringPolicy schedule="0 0 0 * * ?" />
</Policies>
...
</RollingFile>
(https://logging.apache.org/log4j/2.x/manual/appenders.html#Cron_Triggering_Policy)

Related

How to do a every 3 months cron job in laravel?

I am using laravel to schedule a job to run every 3 months at 2am, so I created:
$schedule->command('clean:market-history')->cron( '0 0 0,2 ? 1/3 * *');
But according to my research (by using: this reference) this indicates it will run every 3 months starting in January at 2 am. I got most of it right, I do want it to run every three months at 2 am, but if it starts in January does that not mean if I deploy in august, for example, that it wont start running till January?
Some resources stated to use: */3 how ever, the site, linked above, states the same, starting in January at 2 am.
Is this correct or am I missing something? Can some one explain?
If you want to run your command quarterly (First day of Jan, April, July, October) you can use Laravel's pre-canned quarterly function:
$schedule->command('YourCommandHere')->quarterly('02:00')->timezone('America/New_York');
If you want to run this command every three months starting from time of implementation (ie every 3 months starting now) you can use Laravel's cron function that lets you pass a custom cron line and that cron line would look like this:
$schedule->command('YourCommandHere')->cron('0 2 * */3 *')->timezone('America/New_York');
You can configure any iteration of laravel's cron function. Just use the crontab.guru reference I shared below. It's a lifesaver. Also, don't forgot to define timezone as I do if you intend on using a different timezone than what the server is set to.
To get all of the Laravel schedule features review this documentation: https://laravel.com/docs/8.x/scheduling
My most frequently used url to identify what my cron line should look like: https://crontab.guru

TailFile Processor- Apache Nifi

I'm using Tailfile processor to fetch logs from a cluster(3 nodes) scheduled to run every minute. The log file name changes for every hour
I was confused on which Tailing mode should I use . If I use Single File it is not fetching the new file generated after 1 hour. If I use the multifile, It is fetching the file after 3rd minute of file name change which is increasing the size of the file. what should be the rolling filename for my file and which mode should I use.
Could you please let me know. Thank you
Myfilename:
retrieve-11.log (generated at 11:00)- this is removed but single file mode still checks for this file
after 1 hour retrieve-12.log (generated at 12:00)
My Processor Confuguration:
Tailing mode: Multiple Files
File(s) to Tail: retrieve-${now():format("HH")}.log
Rolling Filename Pattern: ${filename}.*.log
Base Directory: /ext/logs
Initial Start Position: Beginning of File
State Location: Local
Recursive lookup: false
Lookup Frequency: 10 minutes
Maximum age: 24 hours
Sounds like you aren't really doing normal log file rolling. That would be, for example, where you write to logfile.log then after 1 day, you move logfile.log to be logfile.log.1 and then write new logs to a new, empty logfile.log.
Instead, it sounds like you are just writing logs to a different file based on the hour. I assume this means you overwrite each file every 24h?
So something like this might work?
EDIT:
So given that you are doing the following:
At 10:00, `retrieve-10.log` is created. Logs are written here.
At 11:00, `retrieve-11.log` is created. Logs are now written here.
At 11:10, `retrieve-10.log` is moved.
TailFile is only run every 10 minutes.
Then targeting a file based on the hour won't work. At 10:00, your tailFile only reads retrieve-10.log. At 11:00 your tailFile only reads retrieve-11.log. So worst case, you miss 10 minuts of logs between 10:50 and 11:00.
Given that another process is cleaning up the old files, there isn't going to be a back log of old files to worry about. So it sounds like there's no need to set the hour specifically.
tailing mode: multiple files
files to tail: /path/retrieve-*.log
With this, at 10:00, tailFile tails retrieve-9.log and retrieve-10.log. At 10:10, retrieve-9.log is removed and it tails retrieve-10.log. At 11:00 it tails retrieve-10.log and retrieve-11.log. At 11:10, retrieve-10.log is removed and it tails retrieve-11.log. Etc.

How can we schedule nifi data flow ? I'm using HDP 2.5

I want to schedule data flow in daily base through nifi.
For Example,
I need to run schedule on 9.00 AM in every morning.
Can anyone tell me what is procedure to make schedule data flow
There are three scheduling strategy available, see below details
Timer driven: This is the default mode. The Processor will be scheduled to run on a regular interval. The interval at which the Processor is run is defined by the ‘Run schedule’ option (see below).
Event driven: When this mode is selected, the Processor will be triggered to run by an event, and that event occurs when FlowFiles enter Connections feeding this Processor. This mode is currently considered experimental and is not supported by all Processors. When this mode is selected, the ‘Run schedule’ option is not configurable, as the Processor is not triggered to run periodically but as the result of an event. Additionally, this is the only mode for which the ‘Concurrent tasks’ option can be set to 0. In this case, the number of threads is limited only by the size of the Event-Driven Thread Pool that the administrator has configured.
CRON driven: When using the CRON driven scheduling mode, the Processor is scheduled to run periodically, similar to the Timer driven scheduling mode. However, the CRON driven mode provides significantly more flexibility at the expense of increasing the complexity of the configuration. The CRON driven scheduling value is a string of six required fields and one optional field, each separated by a space.
You typically specify values one of the following ways:
Number: Specify one or more valid value. You can enter more than one value using a comma-separated list.
Range: Specify a range using the - syntax.
Increment: Specify an increment using / syntax. For example, in the Minutes field, 0/15 indicates the minutes 0, 15, 30, and 45.
You should also be aware of several valid special characters:
* — Indicates that all values are valid for that field.
?  — Indicates that no specific value is specified. This special character is valid in the Days of Month and Days of Week field.
L  — You can append L to one of the Day of Week values, to specify the last occurrence of this day in the month. For example, 1L indicates the last Sunday of the month.
For example:
The string 0 0 13 * * ? indicates that you want to schedule the processor to run at 1:00 PM every day.
The string 0 20 14 ? * MON-FRI indicates that you want to schedule the processor to run at 2:20 PM every Monday through Friday.
The string 0 15 10 ? * 6L 2011-2017 indicates that you want to schedule the processor to run at 10:15 AM, on the last Friday of every month, between 2011 and 2017.
For your schedule time should be like below;
0109*?** - this meaning every 1 seconds 09 minutes is morning 9 AM other * fields run every day and month.
I hope it helps you!!!
Scheduling Strategy: CRON driven
Run Schedule: 0 0 9 * * ? *

Calculating time between specific logs based on condition

I have a lists of system logs in a log file ,in which I have to calculate time difference between two particular logs based on some condition
#timestamp message
May 19th 2016, 02:55:29.003 just some log
May 19th 2016, 02:55:29.003 retired 2 times
May 19th 2016, 02:55:29.200 System1 down -------
May 19th 2016, 02:55:29.205 just some log
May 19th 2016, 02:55:29.453 System1 up ----
May 19th 2016, 02:55:39.200 System2 down
May 19th 2016, 02:55:49.205 just some log
May 19th 2016, 02:55:53.453 System2 up -------
May 19th 2016, 02:55:58.453 all done
For example in the mentioned log, we need to trigger the calculation when we see the message 'retried' in some log.
On seeing the message it should start the calculating the difference from immediately followed message which contains 'System1 Down' message till it sees the 'System1 Up' message.But here the issue is that the system message can be dynamic like either 'System1' or 'System2'
If it starts with 'System1 Up' , it should calculate time till 'System1 Down'
and same for 'System2 Up'. Is there a possibility to use regex in logstash.
And all the process should stop when it see 'all done' in the message. The time difference calculation should start again if it sees 'retired 2 times' in any of the logs that come below afterwards.
I tired to use elapsed plugin in Logstash and aggregate but not sure, it didn't work for this kinda flow.
What is best to do this? Either in Logstash , elastic search or Kibana.
Thanks in advance

OAS 10g -10.1.2.3.0 forms and reports server, opmn.log is not getting updated

Hi Can you tell which way to drive the analysis for my issue opmn.log is not getting updated. All the instances are working fine and individual instances logs are getting updated but $ORACLE_HOME/opmn/logs/opmn.log is always 0kb since a week time. I could not find any statements reg opmn.log on opmn.xml.
There is a difference in Logging mechanism between (9.0.2 to 10.1.2) and (10.1.3 to later).
(9.0.2 to 10.1.2) log-file path="x" level="x" rotation-size="x"
(10.1.3 to later) log path="x" comp="x;y;z" rotation-size="x"
(9.0.2 to 10.1.2) :
ORACLE_HOME/opmn/logs/ipm.log:
Review the error codes and messages that are shown in the ipm.log file. The PM portion of OPMN generates and outputs the error messages in this file. The ipm.log file tracks command execution and operation progress. The level of detail that gets logged in the ipm.log can be modified by configuration in the opmn.xml file. Refer to Chapter 3, "opmn.xml Common Configuration" for examples of debug levels.
ORACLE_HOME/opmn/logs/ons.log:
Use the ons.log file to debug the ONS portion of OPMN or for early OPMN errors. The ONS portion of OPMN is initialized before PM, and so errors that occur early in OPMN initialization will show up in the ons.log file.
ORACLE_HOME/opmn/logs/opmn.log:
The opmn.log file contains output generated by OPMN when the ipm.log and ons.log files are not available. Typically, the only output written to the opmn.log file will be the exit status of a child OPMN process. A status code of 4 indicates a normal reload of OPMN. All other status codes indicate an abnormal termination of the child OPMN process.
ipm.log(10.1.2) similar to opmn.log(10.1.3)
ons.log(10.1.2) similar to opmn.dbg(10.1.3)

Resources