- NSIS Discussion
- Changing the location of install.log
Archive: Changing the location of install.log
Chilli24
13th February 2005 09:22 UTC
Changing the location of install.log
Hi. I'm using the special build with logging enabled to compile my script. All is ok except the fact that everytime the install.log file is created in the $INSTDIR. Is it possible to change that location? I want the install.log to be created in a specific folder that I will create.
I've tried
SetOutPath "$INSTDIR\$backupFolder"
Rename "$INSTDIR\install.log" '$INSTDIR\$backupFolder\install.log'
but it doesn't work.
Also is it possible to change the name of the file? I want it to be MyFile.log.
Afrow UK
13th February 2005 13:22 UTC
While your installer is running, the log file will obviously be locked for writing. This is why Rename isn't working. Just use
Rename /REBOOTOK "$INSTDIR\install.log" "$INSTDIR\$backupFolder\install.log"
so that it's moved on restart.
Also, are you using a variable $backupFolder to store the backup folder name? Does the user have the option to change that folder name, or does it stay the same throughout the script.
If it stays the same, then you'd be waisting memory on run-time. Not that it matters much, but it's good practice for programs to use as little memory on run-time as possible.
You should use a !define backupFolder "Backup". Then use ${backupFolder} in your script.
-Stu
Chilli24
13th February 2005 13:36 UTC
I don't yhink that the log file is locked for writing because previous to that command I inserted LogSet off. So the install.log file should be free to handle now. Also to move the file after reboot doesn't help me. Because if the isntaller runs twice before reboot, all the actions are logged in the same install.log file. That's why I don't want to use /REBOOTOK. So taking into consideration that LogSet is off, how can I :
- rename the file install.log to, let's say MyProgram.log
- how can I moved it into a folder without rebooting?
P.S. Thanks hor the hint with $backupFolder
Afrow UK
13th February 2005 15:14 UTC
How about making a test script which has LogSet on, then off, and then display a MessageBox (just to pause install).
Then you could try and delete install.log to see if it's still locked or not.
-Stu
kichik
15th February 2005 18:39 UTC
The log file is only closed when the installer closes.
Chilli24
16th February 2005 07:10 UTC
OK. But how can I tell the installer to put the log file in another location, different form $INSTDIR like it is by default ?
kichik
16th February 2005 07:13 UTC
You can't without changing the source.
Chilli24
16th February 2005 07:33 UTC
Ok. Thanks.
mr.hanky
9th February 2006 17:55 UTC
Here is the last thing I do.
CopyFiles /silent "$INSTDIR\install.log" "${MYLOGDIR}\N-2.log"
Delete /REBOOTOK "$INSTDIR\install.log"
*** EDIT ***
Just noticed how old this was.
mtconleyuk
20th September 2012 09:59 UTC
Originally posted by kichik
The log file is only closed when the installer closes.
Is this really true? From the 2.46 code, it looks like handling of a LogSet Off will cause ExecuteEntry() to call log_write(1), which will call CloseHandle(fp) and set <fp> to INVALID_HANDLE_VALUE. That seems as though it should close the file. Is this not right?
Afrow UK
20th September 2012 10:24 UTC
You are right. They probably changed it at some point. After LogSet off, the handle is closed and the file can be renamed even with the installer still running.
Stu
mtconleyuk
20th September 2012 16:31 UTC
Is there some condition under which LogSet On would fail to open the file in the specified location? I have code that looks basically like the following:
LogSet Off
Push $INSTDIR
StrCpy $INSTDIR "$myLogDir"
LogSet On
LogText "Hi there."
Pop $INSTDIR
and on some occasions this will wind up writing the install.log file into the original $INSTDIR folder, not the one I specified! I've stared at the source code, but I can't see any reason why this would happen.
One possible clue is that when this happens, the installer is running with elevated permissions, using UAC::RunElevated. Again, though, I don't see why this should be a problem.
Any thoughts?
Afrow UK
20th September 2012 17:21 UTC
Once you have used LogSet the path is now set for the log. Your LogSet off needs to be removed.
Stu