将信息打印到 shiny-server 日志中

Print information into shiny-server log

有没有办法将 include/print 信息写入 shiny-server 日志文件?

我正在使用一个包含用户登录的闪亮应用程序,如果我的应用程序崩溃,我想知道是什么用户导致了这次崩溃。

我试图将其纳入我的 server.R:

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

但是没用。 有什么想法吗?

试试这个,假设你在这里使用我的回答

  observe({
    if (USER$Logged == FALSE) {

      output$page <- renderUI({
        div(class="outer",do.call(bootstrapPage,c("",ui1())))
      })
    }
    if (USER$Logged == TRUE) {
      output$page <- renderUI({
        div(class="outer",do.call(navbarPage,c(inverse=TRUE,title = "Contratulations you got in!",ui2())))
      })
      cat(paste0("Username: ",input$userName, "\n"))
      cat(paste0("Datum: ",Sys.time(), "\n"))
      print(ui)
    }
  })

file=stderr() 参数添加到您的 cat:

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

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().