Log4j - log file - apache

Does anybody knows how apache log4j handling with streams ?
If it open and close log file for each line or if it simply let open stream and flushing it ?

One thing springs to mind. If log4j keeps the log file open, log rollover fails, because its file handle still points to the old log file. Opening, writing and closing means log4j would correctly grab the file handle for the new log file.

It doesn't open and close the log file for each line (this would cause too much overhead). Output can be buffered (check the documentation). You could create a custom appender that opens the file for appending for every line though, but what are you trying to accomplish?

Related

.conf files - parsing a log message with rsyslog

I have a log file that is read by a conf file like this: (Log file being read by conf file)
These logs are sent to dedicated log viewer service that tags them with a certain severity. The problem at moment is that since all the different types of logs (Info, Debug, Warning, etc.) are stored in one file, they all given the same severity. I have found this article about parsing log messages using rsyslog: https://somoit.net/linux/rsyslog-parsing-splitting-message-fields
Having not much experience with working with these conf files, how can I parse each line from the log file after it has been read in through the input field?
Is declaring variables in conf files done as described in the article? e.g. set $!malware

Apache Nifi - What happens when you run getFile processor without any downstream processor

I am a beginner to Apache Nifi and i want to move a file in my local filesystem from one location to another. When I used the getFile processor to move files from the corresponding input directory and started it, the file disappeared. I haven't connected it to a putFile processor. What exactly is happening here. Where does the file go if it disappears from the local directory i had placed it in. Also how can i get it back?
GetFile has a property Keep Source File, if you have set to true, the file is not deleted after it has been copied from Input Directory to the Content Repository, default is false so this is the reason your files are deleted and you must have set success relation for auto termination otherwise GetFile won't run without any downstream connection. Your files have been discarded. Not sure whether this will work, but try the Data Provenance option and replay content.
Have a look at this - GetFile Official Doc and Replaying a FlowFile

FTP File Copy to be triggered when the file is ready for reading in Mule?

I am new to Mule, so let me say if this is a very basic question then please excuse me.
I am trying to copy a file (size: > 1GB) from one FTP Server(Source) to another FTP Server(Destination).
It takes 1 min to copy the file into the location at which my mule is polling.
As soon as i start copying the file on that location then itself my mule file copy is triggered and tries to read that file and fails as it is still is use by another process.
I wish to make a system in which the file copy is triggered not only when the the mule can detect a file at the Source, but i also want mule to wait for the file to be ready for reading and then start copying it. I don't want to insert a delay of fixed amount for this prupose.
Someone please suggest a method of doing it.
The problem with that readiness is that there is no such kind of standardised flag in the filesystem. So the easier way of doing it is using the ´fileAge´ attribute of the ftp connector, that is sadly EE only.
Can't you move the file to the ftp directory Mule is pollong once is ready to be processed? That wouldn't require copying the file again, so it takes almost no time. Mule would pick it up only when is ready to be processed.

Is it safe to set WinSCP INI file read only to avoid problems during parallel script runs?

We have multiple WinSCP processes to upload/download files from external servers. These jobs run to a schedule but can often overlap as they are running so frequently.
There are occasions where we can successfully upload a file to a server, however WinSCP exits as if it has failed, because it cannot write back to the ini file.
Error writting to file 'c:\progra~1\winSCP\WinSCP.ini'
System Error. Code: 32.
The process cannot access the file because it is being used by another process
It appears that this is due to two or more processes trying to write back to the ini file at the same time.
This is then causing us to treat the files uploaded as failures and re-upload them on the next run (not great when you're dealing with transactional data)
According to the Configuration Guide, we can set the properties of the WinSCP ini file to read-only:
Particularly when using shared INI file, you can set read-only
attribute to the INI file to prevent WinSCP from overwriting the file.
Before making this change, I was hoping someone could tell me the following:
What exactly gets written back to the file?
What issues could arise from setting the file to Read-Only?
Typically, no important data are written after script run, maybe some caches, statistics, etc. You can compare the INI file before and after the run to see yourself.
You can probably turn off all these to avoid WinSCP from writing them, but setting the INI file read only is more reliable and I would recommend it anyway. You would have no problems with that.
Though the best practice is not to rely on external configuration.

How to stop deleting file during download on Mac

I've a client-server application on Mac. Client uploads a file and server downloads the file.
Sever reads a specific size of bytes from the client and write into the file. But in the middle user can delete the file using Finder context menu or from terminal. I want to stop any write/execution operation on this file from any other application till the download runs. It can be easily done using FILE_SHARE_READ while creating the file on Windows. But how we can achieve the same functionality on Mac?
I've tried advisory locks on Mac but no luck. If process A uses advisory locks on the file then process B can't access it but i can always delete the file using Finder context menu.
Are you sure you need to do this? So long as you've got an open file handle, it doesn't matter if the file is deleted, you can still read from it until you close the file handle. If the user deletes the file mid-transmission, it won't stop you from sending the full file.