arXiv:2611.05901cs.SENov 2026

Manuscript Offprint

arXiv:2611.05901

Retrieval Supersedes Scale: Efficient Log Level Prediction via Multiplex Socio-Technical Context

Youssef Esseddiq Ouatiti, Mohammed Sayagh, Bram Adams, Ahmed E. Hassan

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Youssef Esseddiq Ouatiti, Mohammed Sayagh, Bram Adams, and Ahmed E. Hassan

Abstract—Developers insert logging statements in the source code to log its execution. The generated logs are essential for developers in predicting, detecting and troubleshooting system anomalies. A key part of these statements is the log level (e.g., DEBUG, INFO, WARN, ERROR, FATAL), which determines whether a log message is recorded. Choosing an appropriate log level is a complex trade-off as levels set too low (TRACE or DEBUG) mask important information in production, while levels set too high (ERROR or FATAL) create noisy logs and impose extra I/O and storage overhead. A large body of research investigates how to predict the accurate log level for a logging statement leveraging AI approaches. For instance, recent work leverages Large Language Models (LLMs) via In-Context Learning (ICL) to infer the suitable log level for a logging statement. However, current approaches typically augment the prediction prompt with randomly sampled examples. We argue that this diversity-based approach overlooks a critical reality pertaining to the socio-technical nature of logging, where conventions may vary significantly by component and development teams. Consequently, off-the-shelf LLMs using random examples are reported to achieve median AUCs of only 0.56 to 0.76 (across evaluated projects), leaving room for improvement without resorting to fine-tuning techniques. In this paper, we propose a retrieval approach for LLM-powered log level prediction that prioritizes context relevance over random selection of ICL examples and basic similarity approaches typically used in ICL retrieval. Our ICL RAG-based method retrieves logging examples relevant along two socio-technical dimensions: (i) functionality (code performing similar operations) and (ii) ownership (code maintained by the same set of developers). Evaluating four different LLMs across ten popular Java projects, we find that this retrieval improves AUC over random baselines by 0.07 (median). Combining both signals yields median AUCs of 0.83 to 0.97. Furthermore, our ablation studies reveal that each signal improves on random retrieval alone, and that combining them outperforms the stronger of the two on all ten projects. Our AUC results also significantly exceed state-of-the-art standard supervised predictors (e.g., DeepLV) by a median between 0.12 and 0.19 across our evaluated projects. Our findings highlight the importance of leveraging socio-technical signals such as code functionality and ownership to inform LLM-powered log level prediction.

Index Terms—Software Logging, Log Level Prediction, Machine learning, Large language models

1 INTRODUCTION

Developers insert logging statements into the source code of software systems to capture essential runtime information, facilitating debugging, system observability, and anomaly prediction, detection, and diagnosis [17, 33, 39]. A typical logging statement includes a log level (e.g., DEBUG), and a textual message with or without variables. Log levels are typically ordered by verbosity from DEBUG (most verbose) to FATAL (least verbose) in Java logging libraries. Such log levels control the volume of logged data, as during software operation, only log messages at or above a set threshold are recorded, while more verbose messages are excluded. Operators set this threshold through configuration, independently of the levels written in the code.

However, accurately determining the appropriate log level for each logging statement remains a challenging activity for developers [18, 30], who typically make initial poor log level choices [17, 27]. Suboptimal log level decisions have significant practical consequences as a too low log level drastically reduces software observability, complicates debugging, and prolongs failure diagnosis [39], while an excessive log level introduces performance overhead, in-

plates storage, and overwhelms developers with redundant information [38].

To assist developers in log level decision-making process, researchers have proposed various automated Log Level Predictors (LLPs) [1, 14, 16, 18, 20, 21]. Early approaches [1, 16, 18] relied on engineered software features (e.g., cyclomatic complexity) to train shallow classifiers such as ordinal logistic regression. Subsequent research shifted toward deep learning, leveraging learned embeddings of logging statements and their surrounding code context to capture functionality nuances [20, 21]. Most recently, the advent of generative AI has spurred the adoption of Large Language Models (LLMs) for log level prediction, utilizing paradigms ranging from zero-shot inference to few-shot In-Context-Learning (ICL) and fine-tuning (e.g., LoRA) [14].

Current LLM-powered log level prediction approaches typically rely on random or stratified sampling for in-context examples, a practice that implicitly favors data diversity over contextual relevance [14, 23]. While often chosen for simplicity, this design is supported by the assumed benefits of data diversity in deep learning [12], including (1) improved robustness on unseen inputs, (2) mitigation of selection bias, and (3) coverage of all output classes within the limited context window. Consequently, diverse, randomized sampling is widely treated as a reasonable default for conditioning frozen LLMs.

We argue that this approach (i.e., diversity-first) over-

Y.E. Ouatiti, B. Adams and A.E. Hassan are with the School of Computing, Queen's University, Kingston, ON, Canada. M. Sayagh is with the École de Technologie Supérieure, Université de Québec, Montreal, QC, Canada.

© 2026 IEEE. Personal use of this material is permitted. Permission from IEEE must be obtained for all other uses, in any current or future media, including reprinting/republishing this material for advertising or promotional purposes, creating new collective works, for resale or redistribution to servers or lists, or reuse of any copyrighted component of this work in other works.

looks key aspects that are fundamental to the logging practice [29]. Specifically, projects are not a uniform entity, with a single, consistent logging strategy. In reality, distinct components or subsystems often exhibit different logging practices influenced by factors such as code functionality (i.e., what the code does) and developer ownership (i.e., who maintains or frequently changes a file). We hypothesize in this paper that leveraging these internal distinctions can allow existing LLM-powered LLPs to use the most contextually relevant software knowledge, thereby enhancing their predictive accuracy and practical utility.

For example, the SIG-Auth team 1^{1} in the Kubernetes community maintains authentication logic dispersed across the API Server and the Kubelet. These files sit in different components and have distinct functionality, yet they may share logging conventions because the same people write them. Similarly, Hadoop's RetryInvocationHandler and Yarn's RequestHedgingRMFailoverProxyProvider implement the same retry duty in different components, and both log each attempt at DEBUG before escalating once the retries are exhausted, differing only in the terminal severity that each component's failure warrants. Logging conventions are therefore shaped by both shared ownership and functional similarity, and omitting either signal may limit the predictive accuracy of LLM-powered LLPs. We select functionality and ownership as a complementary pair rather than as an exhaustive model of socio-technical context. Functionality represents the technical responsibilities and observability needs of the code, while ownership represents the social and evolutionary context in which local logging conventions develop. Both signals can be derived consistently at file granularity across the studied projects and represented as aligned layers of the same multiplex graph.

In this paper, we investigate the impact of two socio-technical signals (i.e., code functionality and ownership) on the performance of in-context-learning LLM-powered log level prediction. We propose a methodology that extracts and fuses two distinct socio-technical signals (i.e., code functionality and ownership) into the retrieval process. Specifically, we model a studied software project as a two-layer multiplex graph [3, 9], where nodes represent source files and layers represent the distinct relationship types. While the first layer encodes functionality, where edges connect files with high functional similarity, the second layer encodes ownership, where edges connect files maintained by the same group of contributors. By applying community detection on this unified multiplex structure, we partition the project into coherent socio-technical clusters. Finally, for any given target file, we restrict the retrieval of in-context-learning examples exclusively to its assigned cluster, ensuring that the LLM is augmented with examples that are both functionally relevant and aligned with the team's logging conventions.

It is important to distinguish log level prediction from the broader task of end-to-end log generation. While generative tools aim to solve the “cold start” problem by synthesizing messages for unlogged code, they introduce significant risk when applied to existing logging statements as regenerating a full statement can alter developer-tuned message content or variable selection, degrading log quality and increasing code review burden [31]. In practice, developers often simply need to ‘up-shift’ or ‘down-shift’ the visibility of an existing log message without rewriting it. Therefore, log level prediction addresses a distinct calibration problem pertaining to the optimization of the trade-off between observability and overhead for developer-written log messages. Furthermore, our study concerns log level prediction with frozen, out-of-the-box LLMs, where the model parameters remain unchanged and only the in-context-learning examples vary. Although fine-tuning can adapt an LLM to a specific project logging data, it requires a significant amount of labeled training data and parameter optimization, which add training and maintenance costs. Our approach instead keeps the LLM frozen and adapts its context at inference time through carefully retrieved examples. This provides a lighter-weight form of context adaptation and allows us to isolate the contribution of retrieval under identical model and inference configuration.

To evaluate our approach, we answer the following RQs:

RQ1. How does the integration of ownership and functionality signals via multiplex clustering impact the predictive performance of LLM-powered LLPs? Our approach, leveraging both functionality and ownership signals simultaneously via multiplex clustering, achieves a median AUC between 0.83 and 0.97 across our evaluated projects. The approach statistically significantly (Wilcoxon test, α=0.01\alpha = 0.01) outperforms state-of-the-art approaches in LLM-powered log level prediction (in terms of AUC) by a median of 0.07. Moreover, this integration of socio-technical signals enables frozen LLMs to exceed the AUC of prior specialized supervised models (e.g., DeepLV: +0.12, Ordinal Regression: +0.19) while avoiding task-specific model training and ongoing retraining costs.

RQ2. What is the individual contribution of functionality and ownership signals? Leveraging in-context-learning examples retrieved from our file ownership clusters alone statistically significantly enhances the AUC of LLM-powered log level prediction by a median of 0.02 (Wilcoxon test, α=0.01\alpha = 0.01), compared to the state-of-the-art approaches in LLM-powered log level prediction. Furthermore, leveraging in-context-learning examples retrieved from our functionality-only clusters statistically significantly enhances the AUC of LLM-powered log level prediction by a median of 0.05 (Wilcoxon test, α=0.01\alpha = 0.01), compared to the state-of-the-art approaches in LLM-powered log level prediction.

RQ3. Can multiplex Retrieval reduce the computational cost of LLM-powered log level prediction? Our findings indicate that precise context retrieval is more critical than raw model scale. A multiplex-enhanced 7B model outperforms state-of-the-art commercial models, achieving an average AUC of 0.89, surpassing GPT-4o by 0.10 AUC and DeepSeek-V3.2 by 0.16 AUC. We demonstrate that scaling to larger local models (34B) yields diminishing returns, offering only marginal performance gains (+0.01 AUC) at a disproportionate operational cost increase (+322%).

Our findings suggest the adoption of small, self-hosted and context-aware models over general-purpose commercial APIs for LLM-powered log level prediction. We observe

  1. https://github.com/kubernetes/community/tree/master/sig-auth that integrating socio-technical signals (i.e., ownership and functionality) enables smaller models (e.g., 7B) to outperform much larger baselines, proving that precise retrieval supersedes raw parameter scale. We suggest practitioners prioritize self-hosted, batched inference pipelines to balance accuracy with operational efficiency for log level prediction tasks.

References (30)