Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Print information into shiny-server log

Is there a way to include/print information into a shiny-server log file?

I am working with a shiny app which includes an user login and if my app crashes I would like to know what user caused this crash.

I tried to include this into my server.R:

#PRINT FOR LOG FILE------------
cat(paste0("Username: ",userdata$name, "\n"))
cat(paste0("Datum: ",Sys.time(), "\n"))

But it doesn't work. Any ideas?

like image 984
maRtin Avatar asked Feb 06 '23 14:02

maRtin


1 Answers

Add file=stderr() parameter to your cat:

cat(file=stderr(), paste0("Username: ",userdata$name, "\n"))
cat(file=stderr(), paste0("Datum: ",Sys.time(), "\n"))

As noted in this article:

A note about stderr(): in most cases cat("my output") (i.e. printing to standard out) will work correctly, but in others (e.g. inside a renderPrint, which uses capture.output to redirect output), it won’t, so we recommend always sending trace output to stderr().

like image 72
cakraww Avatar answered Feb 08 '23 16:02

cakraww