log4j2 starting from 1 after restarting application - log4j2

Hi I am using log4j2 and using rollover based on time and size. I am using file name as Application.log ,when rollover happens , previous filename appends with index but after system restarts count is again starting from 1 instead of continuing from previous count and its overwriting all existing files. is there way I can avoid it?
if last file name was Application.log.10
if I restart application, when next file roll over it should continue from 11.

Related

MSIX sideloaded app is slow to start after update

I am using MSIX packaging to deploy .NET desktop applications. The app is built by Azure Pipelines and the installation package is deployed to a shared folder on a file server.
When I run the .appinstaller, the dialog opens and applies updates as it should. But then the dialog closes, and nothing happens for over 1 minute. Then the app starts.
TEST 1 - Normal user
Looking in the event log, there is first this warning:
App manifest validation warning: Declared namespace
http://schemas.microsoft.com/developer/appx/2015/build is
inapplicable, it will be ignored during manifest processing.
Then several messages like
error 0x5: Deleting file \?\C:\Program
Files\WindowsApps\Deleted\8b7d5c25-92aa-4962-9e74-93b9685ce2ca-test_2021.1005.1225.1455_x64__002e9dkagpm7g28acfe13-edc2-4d9d-8a69-d5d9687e0573\MyApp\MyApp.exe
failed.
After 1 minute there is this warning:
Warning: There were 129 additional files that failed to be deleted
under the folder \?\C:\Program Files\WindowsApps\Deleted.
It seems that the process tries, and retries, to delete the old files for over 1 minute, then gives up.
How can I allow MSIX to delete the files without giving it administrator rights?
TEST 2 - Administrator user
I did a second test, this time on a different machine, and logged in as an administrator.
The update dialog finished the update and closed after 12s.
Then nothing happened for 5 minutes(!)
I believe I clicked the Start button or something, then suddenly the app started.
Examining the log did not show any warnings about failed file deletions.
Only this warning:
App manifest validation warning: Declared namespace
http://schemas.microsoft.com/developer/appx/2015/build is
inapplicable, it will be ignored during manifest processing.
During the 5 minutes there were no log entries at all.
These were the last 2 log entries, made after 5 minutes:
14-10-2021 10:10:12
UpdateUsingAppInstallerOperation operation on a package with main
parameter
8b7d5c25-92aa-4962-9e74-93b9685ce2ca-test_2021.1013.1518.1578_x64__002e9dkagpm7g
and Options 0 and 0. See http://go.microsoft.com/fwlink/?LinkId=235160
for help diagnosing app deployment issues.
14-10-2021 10:10:13
The bundle streaming reader was created successfully for bundle
8b7d5c25-92aa-4962-9e74-93b9685ce2ca-test_2021.1013.1518.1578_neutral_~_002e9dkagpm7g.Started deploymentThe bundle streaming reader was created
Conclusion
Looking at Task Manager and ProcMon, I can see that the app starts right after the update dialog closes. However, the process is a Background Process, invisible to the user.
While googling, I came across these posts describing the same problem:
https://techcommunity.microsoft.com/t5/msix-deployment/app-does-not-launch-immediately-after-installation-but-after-a/m-p/1972161
https://techcommunity.microsoft.com/t5/msix-deployment/winforms-exe-in-msix-package-does-not-startup-after-auto-update/m-p/965978
You can't give it admin rights. MSIX installations always run per user.
This seems to sound like a machine-related problem. Are you reproducing the same behavior on other machines (try virtual machines if you don't have access to a separate physical machine).
I never found a solution for this. My workaround is to turn off the update dialog by not including ShowPrompt="true".
Then the app seems to launch as it should even if there are updates.
However, there is a new problem - the first time the user starts the app after an update has been released, the auto-update does not happen. It only gets applied the second time the app starts. This is by design apparently...

automation anywhere-For Each file in folder loop command stops after 223 counters also it stop entire module

Automation anywhere's For Each file in folder loop command stop after 223 counters also it stop entire task.
I am getting this issue in only 1 particular folder
although when I am looping through VBA its working fine
I have previously found the cause of this to be when the combined file path and file name exceeds a certain number of characters. I cant remember the exact amount sorry.
It stops the bot without any warning or error message.
Worth checking this out.

Log4j2 not to create new log file after my application restart

I am using Log4j2. My log file name has time stamp like this: app.${date:yyyy-M-dd_hh-mm-ss}.log. I have set max file size to 10MB using SizeBasedTriggeringPolicy. We are good as long as application running. After application restart, new log file getting created even though current log file not reached to the max size due to application restart. Is there any way to use the old log file instead of creating new log file after application restart?
Not with a date in the name. Log4j will resolve the lookup in the name every time the Appender is recreated. There is no way to say "use the date of the newest file that hasn't exceeded the max".

NSLog / Log4Cocoa console logs needs to be saved in file

For my application i need to save all kind of console logs in the text or log file. I am using Log4Cocoa to generating different kind of logs. So how can i save all those console logs into the file? Could anyone please help me.
Thanks
With Log4Cocoa, each logger can have one or more destinations attached to it. So, if you attach a file appender to the root logger object, every log message will be sent to that file. When you initialize the logging system, add something like:
NSString *logFileName = #"path-to-your-log-file";
[[L4Logger rootLogger] addAppender:
[[L4FileAppender alloc] initWithLayout:[L4Layout simpleLayout]
fileName:logFileName];
If you use the L4FileAppender, the file you write to can grow without bounds. So, you might consider using either an L4RollingFileAppender or L4DailyRollingFileAppender instead. The L4RollingFileAppender rolls the file based on file size. The L4DailyRollingFileAppender rolls the file based on time. Despite what the name suggests, you can configure an L4DailRollingFileAppender to roll at different time periods (every minute, every hour, every 1/2 day, etc.).
If you do use a file appender, then you need to give some thought to how you are going to get the log files off of your device, particularly if you need to do logging in the production version of your application.
Much as I like the elegance of Log4Cocoa, I wound up switching to NSLogger (https://github.com/fpillet/NSLogger) and you might want to give it a look.

stacktrace.log file is too large

Inside the target directory of my project, there is a file called stacktrace.log. I have realised size of the file has become more than 3 gigabytes. Is it safe for me to delete this file? Would it cause any file not found exceptions after deleting it? Thanks for your time.
---edit
If it does cause file not found exception, how can I resolve the issue?
stacktrace.log is the default location where Grails writes the unfiltered stack traces of exceptions thrown by the app (for normal logging it filters out stack frames that are "internal" groovy mechanics, but sometimes it can be too aggressive so it's handy to have the full traces available). You can safely delete it and it will get recreated empty next time the app starts.
You can control this in the log4j DSL in Config.groovy, under the appenders block. The default behaviour is equivalent to an appender definition of
file name:'stacktrace', file:'stacktrace.log`
in prod mode and file:'target/stacktrace.log' in dev mode, you could replace it with e.g.
rollingFile name:'stacktrace', file:'stacktrace.log',
maxFileSize:'5MB', maxBackupIndex:2
to limit it to 15MB (the active file plus up to two rolled-over backups).
I guess that is just an log file,If you delete it,the later log will be missing.altough it depends on what logging framwork you are using.
Suggest you to use logback to rolling the log.It can avoid the log to be to Fat.

Resources