feat: add app logging - #2616
Open
ppatel9703 wants to merge 16 commits into
Open
Conversation
Contributor
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
This was referenced Aug 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Producer side of app-owner log visibility: tags log lines with the project they belong to, writes them to a per-project file, and exposes a disk-based search over that file (and its rotated history) for a searchable "Logs" tab. Live tail delivery is not in this repo — that's Monolith#398, which streams this same file over the existing insight websocket. The frontend consuming both is semoss-ui#3302.
Changes Made
src/prerna/sablecc2/comm/PixelJobRunner.javaTags the Log4j2 MDC with
projectIdfor the duration of a pixel job, viainsight.getContextProjectId()— the project this insight is currently scoped to (set bySetContext(...)). Originally readinsight.getProjectId(), a different field entirely ("the project this insight is saved in"), which staysnullfor any transient REPL-style insight — Terminal's, Console's — that's only ever scoped viaSetContext. That bug meant MDC tagging silently never fired for pixels run from Terminal, while looking like it worked everywhere else by coincidence (some other insight-loading paths populate the base field too).log4j2.xmlAdded
[project=%X{projectId}]to the globalConsole/RollingRandomAccessFilepatterns, purely so a human greppingsemossLog.logcan see which project a line belongs to. Unrelated to the per-project routing below.src/prerna/logging/AppLogManager.java(already present, one fix in this PR)Per-project Log4j2
RollingFileAppenderfactory — writes{projectVersionFolder}/logs/app.log(50MB × 10 rotations), filtered to only that project's MDC-tagged events. This PR's fix: now also attaches to the root logger (LogManager.ROOT_LOGGER_NAME), not justprerna/EngineLogger. Custom app reactors almost never live underprerna.*— a typical app's reactors are in their own package (e.g.reactors.vaapi.*), a sibling namespace toprerna, not a descendant, so they fall through to root instead of inheritingprerna's appenders. Without this, a custom reactor's ownlogger.error(...)calls never reached the per-project file no matter how much logging an app author added.Known remaining gap: root's own level threshold (
WARNinlog4j2.xml) still dropsINFO/DEBUGfrom custom packages before any appender sees them — fixing that means lowering Root's level platform-wide, a bigger, separate call.src/prerna/logging/GetAppLogsReactor.java(deleted)Was a polling reactor (
offset/nextOffsetclient-side polling). Superseded entirely — live tail is now a websocket push from Monolith (AppLogStreamer), and historical reads are the new search reactor below. No reactor call is needed for either anymore.src/prerna/logging/SearchAppLogsReactor.java(new)Reads
app.logplus its rotated siblings (app.log.1....10) directly from disk — no database. Filters by text substring and/or level, paginated (offset/limit, capped at 500), newest-first. Owner-gated, same rule the old reactor used (SecurityProjectUtils.getUserProjectPermission+AccessPermissionEnum.isOwner).Deliberately not a DB-backed appender (an
AuditLogsJDBCAppender-style table was the original plan) —app.log's own rotation already bounds storage per project, so a DB would've solved a retention problem that doesn't exist here, at the cost of a new schema/write path with no retention story of its own (the audit-log precedent doesn't have a purge job either).How to Test
{projectVersionFolder}/logs/app.logexists and only contains this project's lines.logger.error(...)/logger.warn(...)call to a custom-package reactor (not underprerna.*) in that app, trigger it, confirm the line shows up inapp.log(this is the root-logger fix — would not have worked before this PR).SearchAppLogs(paramValues=[{"projectId": "<id>", "query": "...", "levels": "ERROR,WARN", "offset": "0", "limit": "50"}]);— confirm results are newest-first, correctly filtered, and paginate viahasMore/totalMatches.SearchAppLogsgets rejected.SetContext'd, neversetProjectId'd directly) — confirm its logs now carry[project=...]in the global log too (thePixelJobRunnerfix).Notes
AppLogStreamer) tails that same file and pushes it live over/insightSocket. semoss-ui has two consumers: a live-tail Console panel (talks to Monolith's socket directly) and a searchable Logs page (talks toSearchAppLogsReactorhere viarunQuery).app.logis local to whichever pod's disk wrote it — no cross-pod visibility in a multi-replica deployment.rclone syncpushes to S3 with no exclude list (only fires from explicit actions — build/publish, upload, GitHub sync — never automatically). Two pods each syncing their own copy will clobber each other's history on whichever push lands last. Not fixed in this PR.docs/app-logs/architecture.mdin the workspace root (not part of this repo).Review Updates
Addressed the following from review:
AppLogManager.java,SearchAppLogsReactor.java,PixelJobRunner.java,Insight.java— this repo's Maven compiler plugin enforcescp1252source encoding, and non-ASCII punctuation risks build/encoding issues.SearchAppLogsReactor: added auser == null || user.getPrimaryLoginToken() == nullguard before dereferencing the token, matching the existing convention elsewhere in the codebase (e.g.AgentRuntimeManager).Insight.java: fixed an unusedFileSystemsimport (was imported but referenced fully-qualified) and corrected import ordering.